﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using EO;
using LoginSqlServer.LIB;

namespace LoginSqlServer
{
    public class LibCommon
    {
        #region "Properties & Event"
        public static string DatabaseName;
        public static string DataAccessObject;
        public static string DataAccessObjectEx; //with space firts

        public static string EntityObject;
        public static string EntityObjectEx; //with space firts
        public static string EntityObjectExx; //with space firts

        public static string _EntityObject;
        public static string _EntityObjectEx; //with space firts
        public static string _EntityObjectExx; //with space firts

        public static string objEntityObject;
        public static string objEntityObjectEx;

        public static string tblFullName;
        public static string UI;
        public static string _DetailUC;
        public static string _DetailUC1;
        public static string _ListUC;
        public static string _ListUC1;
        public static string _NewUC;
        public static string _NewExUC;
        public static Boolean isAddOK;
        public static Boolean isTableAttack;
        #endregion

        public static void fncAspx(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"" + UI + ".aspx.cs\" Inherits=\"" + Constants.Information.ProjectName + "." + UI + "\" %>" +
                        "\n\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" +
                        "\n\n<html xmlns=\"http://www.w3.org/1999/xhtml\">" +
                        "\n<head runat=\"server\">" +
                        "\n\t<title></title>" +
                        "\n\t<script type=\"text/javascript\">" +
                            "\n\t\tfunction CheckAll(oCheckbox) {" +
                                "\n\t\t\tvar grvList = document.getElementById(\"<%=grvList.ClientID %>\");" +
                                "\n\t\t\tfor (i = 1; i < grvList.rows.length; i++) {" +
                                    "\n\t\t\t\tgrvList.rows[i].cells[0].getElementsByTagName(\"INPUT\")[0].checked = oCheckbox.checked;" +
                                "\n\t\t\t}" +
                            "\n\t\t}" +
                        "\n\t</script>" +
                        "\n</head>" +
                        "\n<body>" +
                        "\n\t<form id=\"form1\" runat=\"server\">" +
                        "\n\t<div class=\"wrapper\">" +
                        "\n\t<asp:MultiView ID=\"mtvMain\" runat=\"server\" ActiveViewIndex=\"0\">" +
                        "\n\t<asp:View ID=\"vList\" runat=\"server\" >" +
                        "\n\t<table id=\"tblList\" style=\"border-collapse: collapse\" cellpadding=\"0\" width=\"100%\" border=\"0\">\n" +
                        "\n\t\t<tr>\n" +
                        "\n\t\t\t<td>\n" +
                        "\n\t\t\t\t<asp:Button ID=\"btnRefresh\" runat=\"server\" CssClass=\"btnRefresh\" Text=\"Làm mới\" onclick=\"btnRefresh_Click\" />" +
                        "<asp:Button ID=\"btnInsertNew\" runat=\"server\" CssClass=\"btnInsert\" Text=\"Thêm mới\" onclick=\"btnInsertNew_Click\" />" +
                        "<asp:Button ID=\"btnDeleteList\" runat=\"server\" CssClass=\"btnDeleteList\" Text=\"Xóa\" onclick=\"btnDeleteList_Click\" />" +
                        "<asp:Button ID=\"btnExportExcel\" runat=\"server\" CssClass=\"btnExportExcel\" Text=\"Xuất ra Excel\" onclick=\"btnExportExcel_Click\" />\n" +
                        "\n\t\t\t</td>\n" +
                        "\n\t\t</tr>\n" +
                        "\n<tr>" +
                        "\n<td>" +
                        "\n<asp:Panel ID=\"pnlSearch\" runat=\"server\" Visible=\"true\">" +
                        "\n<asp:TextBox ID=\"txtTextSearch\" runat=\"server\"></asp:TextBox>" +
                        "\n<asp:DropDownList ID=\"ddlTypeSearch\" runat=\"server\" ontextchanged=\"ddlTypeSearch_TextChanged\">" +
                        "\n<asp:ListItem Value=\"0\">Tìm theo mã</asp:ListItem>" +
                        "\n<asp:ListItem Value=\"1\">Tìm theo tên</asp:ListItem>" +
                        "\n</asp:DropDownList>" +
                        "\n<asp:Button ID=\"btnSearch\" runat=\"server\" Text=\"Tìm kiếm\" onclick=\"btnSearch_Click\" />" +
                        "\n</asp:Panel>" +
                        "\n</td>" +
                        "\n</tr>" +
                        "\t\t<tr>\n" +
                        "\t\t\t<td height=\"6\">\n");
            #region GridView
            sb.Append("\t\t\t\t<asp:GridView ID=\"grvList\" runat=\"server\" CssClass=\"mGrid\" " +
                    "\nAutoGenerateColumns=\"False\" AutoGenerateCheckBoxColumn=\"True\" " +
                    "\nFileTypeDownload=\"Excel\" Width=\"100%\" AllowPaging=\"True\" datakeynames=\"");
            foreach (var item in colName)
            {
                if (item.bPrimaryKey)
                {
                    isAddOK = true;
                    sb.Append(item.sColumnName + ",");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\" " +
            "\nemptydatatext=\"Không có bản ghi nào.\"" +
            "\nEnableModelValidation=\"True\" onrowcommand=\"grvList_RowCommand\" " +
            "\nonselectedindexchanged=\"grvList_SelectedIndexChanged\" " +
            "\nonpageindexchanging=\"grvList_PageIndexChanging\" " +
            "\nonrowdatabound=\"grvList_RowDataBound\"  PageSize=\"10\" " +
            "\nAllowSorting=\"true\" onsorting=\"grvList_Sorting\">" +
            "\n<AlternatingRowStyle CssClass=\"GridAlternatingItem\"></AlternatingRowStyle>" +
            "\n\t<Columns>" +
                "\n\t\t<asp:TemplateField>" +
                    "\n\t\t\t<HeaderTemplate>" +
                        "\n\t\t\t\t<input id=\"Checkbox2\" type=\"checkbox\" onclick=\"CheckAll(this)\" runat=\"server\" />" +
                    "\n\t\t\t</HeaderTemplate>" +
                    "\n\t\t\t<ItemTemplate>" +
                        "\n\t\t\t\t<asp:CheckBox ID=\"ItemCheckBox\" runat=\"server\" />" +
                    "\n\t\t\t</ItemTemplate>" +
               "\n\t\t</asp:TemplateField>" +
               "\n\t\t<asp:TemplateField>" +
                    "\n\t\t\t<ItemTemplate>" +
                        "\n\t\t\t\t<asp:LinkButton ID=\"cmdDetail\" runat=\"server\" CommandName=\"cmdView\" Width=\"90px\" CommandArgument='<%#Container.DataItemIndex %>'>Chi tiết</asp:LinkButton>" +
                        "\n\t\t\t\t</ItemTemplate>" +
                    "\n\t\t\t<ItemStyle HorizontalAlign=\"Center\"  />" +
                "\n\t\t</asp:TemplateField>" +
                "");
            foreach (var item in colName)
            {
                sb.Append("\n\t\t<asp:BoundField  DataField=\"" + item.sColumnName + "\"  HeaderText=\"" + item.sColumnName + "\" SortExpression=\"" + item.sColumnName + "\">" +
                    "\n\t\t\t<ItemStyle CssClass=\"" + ConvertNew.ConvertDataTypeToStyle(item) + "\"/>" +
                "\n\t\t</asp:BoundField>");
            }
            sb.Append("\n\t</Columns>" +
                    "\n\t<RowStyle CssClass=\"GridItem\"></RowStyle>" +
                    "\n\t<HeaderStyle CssClass=\"GridHeader\"></HeaderStyle>" +
                    "\n\t<FooterStyle CssClass=\"GridFooter\"></FooterStyle>" +
                    "\n</asp:GridView>");
            #endregion
            sb.Append("\t\t\t</td>\n\t\t</tr>" +
                        "\t\t<tr>\t\t\t<td><asp:Label id=\"lblRowCount\" runat=\"server\" ForeColor=\"Blue\"></asp:Label>" +
                        "\t\t\t</td>" +
                        "\t\t</tr>" +
                        "\n\t</table>\n" +
                        "</asp:View>\n" +
                        "\n\t<asp:View ID=\"vDetail\" runat=\"server\" >" +
                        "<asp:LinkButton ID=\"lbtnBack\" runat=\"server\" onclick=\"lbtnBack_Click\">Quay lại danh sách</asp:LinkButton><br />" +
                        "\t<table id=\"tblDetail\" style=\"border-collapse: collapse\" cellpadding=\"0\" width=\"100%\" border=\"0\">\n" +
                        "\t\t<tr>\n" +
                        "\t\t\t<td></td>\n" +
                        "\t\t\t<td></td>\n" +
                        "\t\t</tr>\n" +
                        "\t\t<tr>\n" +
                        "\t\t\t<td></td>\n" +
                        "\t\t\t<td>\n" +
                        "\t\t\t\t<asp:Label id=\"lblTitle\" runat=\"server\" ForeColor=\"Blue\"></asp:Label><br /><br />\n" +
                        "\t\t\t\t<asp:Label id=\"lblMsg\" runat=\"server\" ForeColor=\"Red\"></asp:Label>\n\t\t\t</td>\n" +
                        "\t\t</tr>\n");
            foreach (var item in colName)
            {
                if (!item.bForeignKey)
                {
                    sb.Append("\t\t<tr>\n");
                    sb.Append("\t\t\t<td class=\"name_field_row\">");
                    sb.Append(item.sColumnName + ":</td>\n");
                    sb.Append("\t\t\t<td class=\"field_row\">\n");
                    sb.Append("\t\t\t\t<asp:TextBox id=\"txt" + item.sColumnName + "\" runat=\"server\" Width=\"200px\"></asp:TextBox>\n\t\t\t</td>\n");
                    sb.Append("\t\t\t<td class=\"notify_fild_row\">\n");
                    sb.Append("\t\t\t\t<asp:Label id=\"lbl" + item.sColumnName + "\" runat=\"server\"></asp:Label>\n\t\t\t</td>\n");
                    sb.Append("\t\t</tr>\n");
                }
                else
                {
                    sb.Append("\t\t<tr>\n");
                    sb.Append("\t\t\t<td class=\"name_field_row\">");
                    sb.Append(item.sColumnName + ":</td>\n");
                    sb.Append("\t\t\t<td class=\"field_row\">\n");
                    sb.Append("\t\t\t\t<asp:DropDownList id=\"ddl" + item.sColumnName + "\" runat=\"server\" Width=\"200px\"></asp:DropDownList>\n\t\t\t</td>\n");
                    sb.Append("\t\t\t<td class=\"notify_fild_row\">\n");
                    sb.Append("\t\t\t\t<asp:Label id=\"lbl" + item.sColumnName + "\" runat=\"server\"></asp:Label>\n\t\t\t</td>\n");
                    sb.Append("\t\t</tr>\n");
                }
            }
            sb.Append("\t\t<tr>\n" +
                        "\t\t\t<td></td>\n" +
                        "\t\t\t<td>" +
                        "\n\t\t\t\t<asp:Button ID=\"btnInsert\" CssClass=\"btnInsert\" runat=\"server\" OnClick=\"btnInsert_Click\" Text=\"Thêm mới\" />" +
                        "\n\t\t\t\t<asp:Button ID=\"btnUpdate\" CssClass=\"btnUpdate\" runat=\"server\" OnClick=\"btnUpdate_Click\" Text=\"Cập nhật\" />" +
                        "\n\t\t\t\t<asp:Button ID=\"btnDelete\" CssClass=\"btnDelete\" runat=\"server\" OnClick=\"btnDelete_Click\" Text=\"Xóa\" />" +
                        "\n\t\t\t\t<asp:Button ID=\"btnReset\" CssClass=\"btnInsert\" runat=\"server\" OnClick=\"btnReset_Click\" Text=\"Làm mới\" />" +
                        "\n\t\t\t</td>\n" +
                        "\t\t</tr>\n" +
                        "\t</table>\n" +
                        "</asp:View>\n" +
                        "</asp:MultiView>\n" +
                        "\n\t</div>" +
                        "\n\t</form>" +
                        "\n</body>" +
                        "\n</html>");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Aspx, tbName, Constants.FileExtension.Aspx), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncAspxCs(List<ColumnEO> colName, string tbName)
        {
            var sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web;" +
                        "\nusing System.Web.UI;" +
                        "\nusing System.Web.UI.WebControls;" +
                        "\nusing System.Data;" +
                        "\nusing System.Drawing;" +
                        "\nusing SharedLibraries;" +
                        "\nusing EntityObject;" +
                        "\nusing DataAccessObject;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace " + Constants.Information.ProjectName +
                        "\n{" +
                        "\n\tpublic partial class " + UI + " : System.Web.UI.Page" +
                        "\n\t{");


            sb.Append("\n\t\t#region \"Properties & Event\"" +
                        "\n\t\tpublic event EventHandler ViewDetail;" +
                        "\n\t\tpublic event EventHandler SelectRow;" +
                        "\n\t\tpublic event EventHandler AddNew;" +
                        "\n\t\tpublic string typesearch" +
                        "\n\t\t{" +
                        "\n\t\t\tget { return (string)ViewState[\"typesearch\"]; }" +
                        "\n\t\t\tset { ViewState[\"typesearch\"] = value; }" +
                        "\n\t\t}" +
                        "\n\t\t#endregion");
            sb.Append("\n\t\tprivate " + EntityObject + " _" + objEntityObject + ";" +
                            "\n\t\tpublic " + EntityObject + " " + objEntityObject +
                            "\n\t\t{" +
                                "\n\t\t\tget { return this._" + objEntityObject + "; }" +
                                "\n\t\t\tset { _" + objEntityObject + " = value; }" +
                            "\n\t\t}");
            sb.Append("\n\t\tprotected void Page_Load(object sender, EventArgs e)" +
                    "\n\t\t{" +
                    "\n\t\t\ttry" +
                    "\n\t\t\t{" +
                    "\n\t\t\t\tif(!IsPostBack)" +
                    "\n\t\t\t\t{" +
                    "\n\t\t\t\t\tBindDataGrid();" +
                    "\n\t\t\t\t\tBindDataDdl();" +
                    "\n\t\t\t\t\tClearMessages();" +
                    "\n\t\t\t\t}" +
                    "\n\t\t\t}" +
                    "\n\t\t\tcatch (Exception)" +
                    "\n\t\t\t{" +
                    "\n\t\t\t\tlblMsg.Text=Messages.Loi;" +
                    "\n\t\t\t}" +
                    "\n\t\t}\n");

            sb.Append("\n\t\tpublic void BindDataGrid()" +
                        "\n\t\t{" +
                        "grvList.Visible = false;" +
            "\n\t\t\tstring keysearch = txtTextSearch.Text;" +
            "\n\t\t\tDataTable dt = " + DataAccessObject + ".SelectList();" +
            "\n\t\t\tvar result =" +
                "\n\t\t\t\tfrom topic in dt.AsEnumerable()" +
                "\n\t\t\t\tselect new" +
                "\n\t\t\t\t{");
            foreach (var item in colName)
            {
                isAddOK = true;
                sb.Append("\n\t\t\t\t\t" + item.sColumnName + " = topic.Field<" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + ">(\"" + item.sColumnName + "\"),");
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            string a = colName[0].sColumnName, b = colName[1].sColumnName;
            sb.Append("\n\t\t\t\t};" +
        "\n\t\t\tddlTypeSearch.SelectedValue = typesearch;" +
        "\n\t\t\tif (Convert.ToInt16(ddlTypeSearch.SelectedValue) == 0)" +
        "\n\t\t\t{" +
            "\n\t\t\t\tif (keysearch != \"\")" +
            "\n\t\t\t\t{" +
                "\n\t\t\t\t\tvar search = (from item in result where item." + a + ".ToString().ToUpper().Contains(keysearch.ToString().ToUpper().Trim()) select item);" +
                "\n\t\t\t\t\tresult = search;" +
            "\n\t\t\t\t}" +
        "\n\t\t\t\t}" +
        "\n\t\t\t\telse" +
        "\n\t\t\t\t{" +
            "\n\t\t\t\t\tif (keysearch != \"\")" +
            "\n\t\t\t\t\t{" +
                "\n\t\t\t\t\t\tvar search = (from item in result where item." + b + ".ToString().ToUpper().Contains(keysearch.ToString().ToUpper().Trim()) select item);" +
                "\n\t\t\t\t\t\tresult = search;" +
            "\n\t\t\t\t\t}" +
        "\n\t\t\t\t}" +
        "\n\t\t\t\tif (result.Count() > 0)" +
        "\n\t\t\t\t{" +
            "\n\t\t\t\t\tgrvList.Visible = true;" +
            "\n\t\t\t\t\tgrvList.DataSource = result.ToList();" +
            "\n\t\t\t\t\tgrvList.DataBind();" +
            "\n\t\t\t\t\tlblRowCount.Text = Messages.Tong_So_Ban_Ghi + result.Count();" +
        "\n\t\t\t\t}" +
        "\n\t\t\t\telse" +
        "\n\t\t\t\t{" +
            "\n\t\t\t\t\tlblRowCount.Text = Messages.Khong_Thoa_Man_Dieu_Kien_Tim_Kiem;" +
        "\n\t\t\t\t}" +
        "\n\t\t}\n");

            sb.Append("\n\t\tpublic void BindDataDdl()" +
                        "\n\t\t{" +
                        "\n\t\t\tDataTable dt = new DataTable();" +
                        "\n\t\t\tdt = " + DataAccessObject + ".SelectList();" +
                        "\n\t\t\tthis.grvList.DataSource = dt;" +
                        "\n\t\t\tthis.grvList.DataBind();" +
                        "\n\t\t\tdt.Clear();" +
                        "\n\t\t\tdt = null;" +
                        "\n\t\t}\n");

            sb.Append("\n\t\tpublic void BindDataDetail(" + EntityObject + _EntityObject + ")" +
                        "\n\t\t{");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    sb.Append("\n\t\t\tthis.txt" + colName[i].sColumnName + ".Text = Convert.ToString(" + _EntityObject + "." + colName[i].sColumnName + ");");
                }
                else
                {
                    sb.Append("\n\t\t\tthis.ddl" + colName[i].sColumnName + ".SelectedValue = Convert.ToString(" + _EntityObject + "." + colName[i].sColumnName + ");");
                }
            }
            sb.Append("\n\t\t}\n");

            sb.Append("\n\t\tpublic void ClearMessages()" +
            "\n\t\t{");
            for (int i = 0; i < colName.Count; i++)
            {
                sb.Append("\n\t\t\tlbl" + colName[i].sColumnName + ".Text = \"\";");
            }
            sb.Append("\n\t\t}\n");


            sb.Append("\n\t\tpublic bool CheckInput()" +
            "\n\t\t{");
            for (int i = 0; i < colName.Count; i++)
            {
                if (colName[i].bAllowNulls == false && !colName[i].bForeignKey)
                {
                    sb.Append("\n\t\t\tif (string.IsNullOrEmpty(txt" + colName[i].sColumnName + ".Text) == true)" +
                                "\n\t\t\t{" +
                                "\n\t\t\t\tlbl" + colName[i].sColumnName + ".Text = Messages.Khong_Duoc_De_Trong;" +
                                "\n\t\t\t\ttxt" + colName[i].sColumnName + ".Focus();" +
                                "\n\t\t\t\treturn false;" +
                                "\n\t\t\t}");
                }
            }
            sb.Append("\n\t\t\treturn true;" +
                        "\n\t\t}\n");


            sb.Append("\n\t\tpublic " + EntityObject + " GetObject()" +
            "\n\t\t{" +
            "\n\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
            "\n\t\t\ttry" +
            "\n\t\t\t{");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    if (colName[i].sSQL_DataType == "float")
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =float.Parse(this.txt" + colName[i].sColumnName + ".Text);");
                    }
                    else
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(colName[i]) + "(this.txt" + colName[i].sColumnName + ".Text);");
                    }
                }
                else
                {
                    if (colName[i].sSQL_DataType == "float")
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =float.Parse(this.ddl" + colName[i].sColumnName + ".SelectedValue);");
                    }
                    else
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(colName[i]) + "(this.ddl" + colName[i].sColumnName + ".SelectedValue);");
                    }

                }
            }
            sb.Append("\n\t\t\t\treturn " + _EntityObject + ";" +
            "\n\t\t\t}" +
            "\n\t\t\tcatch{" +
            "\n\t\t\t\treturn " + _EntityObject + ";" +
            "\n\t\t\t}" +
            "\n\t\t}\n");

            sb.Append("\n\t\tprotected void grvList_RowCommand(object source, GridViewCommandEventArgs e)" +
            "\n\t\t{" +
            "\n\t\t\tif (e.CommandName == \"cmdView\")" +
            "\n\t\t\t{" +
                "\n\t\t\t\tGridViewRow row = this.grvList.SelectedRow;" +
                "\n\t\t\t\tint index = Convert.ToInt16(e.CommandArgument) % grvList.PageSize;" +
                "\n\t\t\t\t" + objEntityObject + " = new " + EntityObject + "();");
            foreach (var item in colName)
            {
                if (item.bPrimaryKey)
                {
                    sb.Append("\n\t\t\t\t" + objEntityObject + "." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + " (grvList.DataKeys[index].Values[\"" + item.sColumnName + "\"]);");
                }
            }
            sb.Append("\n\t\t\t" + objEntityObject + " = " + DataAccessObject + ".SelectItem(" + objEntityObject + ");" +
                "\n\t\t\tBindDataDetail(" + objEntityObject + ");" +
                        "\n\t\t\tmtvMain.ActiveViewIndex = 1;" +
                        "\n\t\t\t\tif (ViewDetail != null)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tViewDetail(this, EventArgs.Empty);" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n");

            sb.Append("\n\t\tprotected void grvList_SelectedIndexChanged(object sender, EventArgs e)" +
            "\n\t\t{" +
            "\n\t\t\tforeach (GridViewRow row in grvList.Rows)" +
            "\n\t\t\t{" +
                "\n\t\t\t\tif (row.RowIndex == grvList.SelectedIndex)" +
                "\n\t\t\t\t{" +
                    "\n\t\t\t\t\trow.BackColor = ColorTranslator.FromHtml(\"#A1DCF2\");" +
                    "\n\t\t\t\t\trow.ToolTip = string.Empty;" +
                "\n\t\t\t\t}" +
                "\n\t\t\t\telse" +
                "\n\t\t\t\t{" +
                    "\n\t\t\t\t\trow.BackColor = ColorTranslator.FromHtml(\"#FFFFFF\");" +
                    "\n\t\t\t\t\trow.ToolTip = \"Click to select this row.\";" +
                "\n\t\t\t\t}" +
            "\n\t\t\t}" +
            "\n\t\t}\n");

            sb.Append("\n\t\tprotected void grvList_PageIndexChanging(object sender, GridViewPageEventArgs e)" +
            "\n\t\t{" +
            "\n\t\t\tgrvList.PageIndex = e.NewPageIndex;" +
            "\n\t\t\tBindDataGrid();" +
            "\n\t\t}\n");

            sb.Append("\n\t\tprotected void grvList_RowDataBound(object sender, GridViewRowEventArgs e)" +
            "\n\t\t{" +
            "\n\t\t}\n");

            sb.Append("\n\t\tprotected void grvList_Sorting(object sender, GridViewSortEventArgs e)" +
            "\n\t\t{" +
            "\n\t\t\tstring sortingDirection = string.Empty;" +
            "\n\t\t\tif (direction == SortDirection.Ascending)" +
            "\n\t\t\t{" +
                "\n\t\t\t\tdirection = SortDirection.Descending;" +
                "\n\t\t\t\tsortingDirection = \"DESC\";" +
            "\n\t\t\t}" +
            "\n\t\t\telse" +
            "\n\t\t\t{" +
                "\n\t\t\t\tdirection = SortDirection.Ascending;" +
                "\n\t\t\t\tsortingDirection = \"ASC\";" +
            "\n\t\t\t}" +
            "\n\t\t\tDataTable dt = " + DataAccessObject + ".SelectList();" +
            "\n\t\t\tDataView sortedView = new DataView(dt);" +
            "\n\t\t\tsortedView.Sort = e.SortExpression + \" \" + sortingDirection;" +
            "\n\t\t\tSession[\"objects\"] = sortedView;" +
            "\n\t\t\tgrvList.DataSource = sortedView;" +
            "\n\t\t\tgrvList.DataBind();" +
            "\n\t\t}\n");

            sb.Append("\n\t\tpublic SortDirection direction" +
            "\n\t\t{" +
                "\n\t\t\tget" +
                "\n\t\t\t{" +
                    "\n\t\t\t\tif (ViewState[\"directionState\"] == null)" +
                    "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tViewState[\"directionState\"] = SortDirection.Ascending;" +
                    "\n\t\t\t\t}" +
                    "\n\t\t\t\treturn (SortDirection)ViewState[\"directionState\"];" +
                "\n\t\t\t\t}" +
                "\n\t\t\t\tset" +
                "\n\t\t\t\t{ ViewState[\"directionState\"] = value; }" +
            "\n\t\t}");

            sb.Append("\n\t\tprotected void btnInsert_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t\tClearMessages();" +
                        "\n\t\t\tlblMsg.Text = \"\";" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif(CheckInput() == true)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tif(" + DataAccessObject + ".Insert(GetObject())==true)" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tlblMsg.Text = Messages.Them_Thanh_Cong;" +
                        "\n\t\t\t\t\t\tClearMessages();" +
                        "\n\t\t\t\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                        "\n\t\t\t\t\t\tBindDataDetail(" + _EntityObject + ");" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tlblMsg.Text = Messages.Them_That_Bai;" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tlblMsg.Text = Messages.Loi + ex.Message;" +
                        "\n\t\t\t}" +
                        "\n\t\t}");


            sb.Append("\n\t\tprotected void btnSearch_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t\tBindDataGrid();" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void ddlTypeSearch_TextChanged(object sender, EventArgs e)" +
                        "\n\t\t{" +
                            "\n\t\t\ttypesearch = ddlTypeSearch.SelectedValue;" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void btnUpdate_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t\tClearMessages();" +
                        "\n\t\t\tlblMsg.Text = \"\";" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif(CheckInput() == true)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tif(" + DataAccessObject + ".Update(GetObject())==true)" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tlblMsg.Text = Messages.Sua_Thanh_Cong;" +
                        "\n\t\t\t\t\t\tClearMessages();" +
                        "\n\t\t\t\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                        "\n\t\t\t\t\t\tBindDataDetail(" + _EntityObject + ");" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tlblMsg.Text = Messages.Sua_That_Bai;" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tlblMsg.Text = Messages.Loi + ex.Message;" +
                        "\n\t\t\t}" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void btnDelete_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t\tClearMessages();" +
                        "\n\t\t\tlblMsg.Text = \"\";" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif(" + DataAccessObject + ".Delete(GetObject())==true)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tlblMsg.Text = Messages.Xoa_Thanh_Cong;" +
                        "\n\t\t\t\t\tClearMessages();" +
                        "\n\t\t\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                        "\n\t\t\t\t\tBindDataDetail(" + _EntityObject + ");" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tlblMsg.Text = Messages.Xoa_That_Bai;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tlblMsg.Text = Messages.Loi + ex.Message;" +
                        "\n\t\t\t}" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void btnReset_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "ClearMessages();" +
                        "lblMsg.Text = \"\";" +
                        "\n\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                        "\n\t\t\tBindDataDetail(" + _EntityObject + ");" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void btnRefresh_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t\tBindDataGrid();" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void btnInsertNew_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t\tmtvMain.ActiveViewIndex = 1;" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void btnDeleteList_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t}");

            sb.Append("\n\t\tprotected void btnExportExcel_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t}");
            sb.Append("\n\t\tprotected void lbtnBack_Click(object sender, EventArgs e)" +
                        "\n\t\t{" +
                        "\n\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                        "\n\t\t\tBindDataDetail(" + _EntityObject + ");" +
                        "\n\t\t\tmtvMain.ActiveViewIndex = 0;" +
                        "\n\t\t\tBindDataGrid();" +
                        "\n\t\t}");

            sb.Append("\n\t}\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.AspxCs, tbName, Constants.FileExtension.AspxCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncAspxDesignerCs(List<ColumnEO> colName, string tbName)
        {
            var sb = new StringBuilder();
            #region "Auto-Generated Default"
            sb.Append("//------------------------------------------------------------------------------" +
                        "\n// <auto-generated>" +
                        "\n//     This code was generated by a tool." +
                        "\n//" +
                        "\n//     Changes to this file may cause incorrect behavior and will be lost if" +
                        "\n//     the code is regenerated." +
                        "\n// </auto-generated>" +
                        "\n//------------------------------------------------------------------------------" +
                        "\nnamespace " + Constants.Information.ProjectName + " {" +
                        "\n\tpublic partial class " + UI + "{\n");

            DataSet ds = new DataSet();
            string ID;
            string Type;
            try
            {
                string xmlFilePath = System.IO.Directory.GetCurrentDirectory() + "\\App_Data\\WebControl.xml";
                ds.ReadXml(xmlFilePath);
            }
            catch { }
            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    ID = dr["ID"].ToString();
                    Type = dr["Type"].ToString();

                    sb.Append("\n\t\t/// <summary>" +
                            "\n\t\t/// " + ID + " control." +
                            "\n\t\t/// </summary>" +
                            "\n\t\t/// <remarks>" +
                            "\n\t\t/// Auto-generated field." +
                            "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                            "\n\t\t/// </remarks>" +
                            "\n\t\tprotected global::System.Web.UI." + Type + " " + ID + ";\n");
                }
            }
            #endregion

            foreach (ColumnEO item in colName)
            {
                sb.Append("\n\t\t/// <summary>" +
                        "\n\t\t/// lbl" + item.sColumnName + " control." +
                        "\n\t\t/// </summary>" +
                        "\n\t\t/// <remarks>" +
                        "\n\t\t/// Auto-generated field." +
                        "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                        "\n\t\t/// </remarks>" +
                        "\n\t\tprotected global::System.Web.UI.WebControls.Label lbl" + item.sColumnName + ";\n");
                if (!item.bForeignKey)
                {
                    sb.Append("\n\t\t/// <summary>" +
                    "\n\t\t/// txt" + item.sColumnName + " control." +
                    "\n\t\t/// </summary>" +
                    "\n\t\t/// <remarks>" +
                    "\n\t\t/// Auto-generated field." +
                    "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                    "\n\t\t/// </remarks>" +
                    "\n\t\tprotected global::System.Web.UI.WebControls.TextBox txt" + item.sColumnName + ";\n");
                }
                else
                {
                    sb.Append("\n\t\t/// <summary>" +
                    "\n\t\t/// ddl" + item.sColumnName + " control." +
                    "\n\t\t/// </summary>" +
                    "\n\t\t/// <remarks>" +
                    "\n\t\t/// Auto-generated field." +
                    "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                    "\n\t\t/// </remarks>" +
                    "\n\t\tprotected global::System.Web.UI.WebControls.DropDownList ddl" + item.sColumnName + ";\n");
                }
            }
            sb.Append("\n\t}\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.AspxDesignerCs, tbName, Constants.FileExtension.AspxDesignerCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncDataAccessObject(List<ColumnEO> colName, string tbName)
        {
            var sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Data;" +
                        "\nusing System.Data.SqlClient;" +
                        "\nusing EntityObject;" +
                        "\nusing ThangNM_LIB.DB;" +
                        "\nusing ThangNM_LIB.FUNC;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace DataAccessObject" +
                        "\n{" +
                        "\n\tpublic class " + DataAccessObject + " : MSSqlDataProvider\n\t{" +
                        "\n\t\tpublic override Boolean bWriteLog { get { return false; } set { } }" +
                        "\n\t\tpublic override String sConnectionStrings { get { return ConstEx.connectionStrings.connMSSql_DF; } set { } }\n" +
                        "\n\t\tpublic " + DataAccessObject + "(Boolean _bWriteLog = true, String _sConnectionStrings = ConstEx.connectionStrings.connMSSql_DF)" +
                        "\n\t\t{" +
                        "\n\t\t\tthis.bWriteLog = _bWriteLog;" +
                        "\n\t\t\tthis.sConnectionStrings = _sConnectionStrings;" +
                        "\n\t\t}");
            string listcolumn = ""; int k = 0;
            #region CheckExists
            sb.Append("\n\t\tpublic Boolean CheckExists(" + EntityObject + " objInput)" +
                        "\n\t\t{" +
                        "\n\t\t\tSqlCommand cmd = new SqlCommand(\"" + tbName + "_CheckExists\");" +
                        "\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;");
            foreach (ColumnEO s in colName)
            {
                if (s.bPrimaryKey && !s.bTableAttack)
                    sb.Append("\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@" + s.sColumnName + "\", NullEx.getNullValue(objInput." + s.sColumnName + ")));");
            }
            sb.Append("\n\t\t\treturn ExecuteNonQuery_RetBool(cmd, true);" +
            "\n\t\t}\n");
            #endregion
            #region Insert_Update_Delete
            listcolumn = "";
            k = 0;
            foreach (ColumnEO item in colName)
            {
                listcolumn += ConvertNew.ConvertDataTypeSQLtoCsharp(item) + " " + item.sColumnName.ToString();
                if (k < colName.Count - 1)
                    listcolumn += ",";
                k++;
            }
            sb.Append("\n\t\tpublic Boolean Insert_Update_Delete(" + EntityObject + " objInput, Int16 _Insert_Update_Delete)" +
                        "\n\t\t{" +
                        "\n\t\t\tSqlCommand cmd = new SqlCommand(\"" + tbName + "_Insert_Update_Delete\");" +
                        "\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;");
            foreach (ColumnEO item in colName)
            {
                if (ConvertNew.CheckIsNumber(item))
                    sb.Append("\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@" + item.sColumnName + "\", objInput." + item.sColumnName + "));");
                else
                    sb.Append("\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@" + item.sColumnName + "\", NullEx.getNullValue(objInput." + item.sColumnName + ")));");
            }
            sb.Append("\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@Insert_Update_Delete\", _Insert_Update_Delete));");
            sb.Append("\n\t\t\treturn ExecuteNonQuery_RetBool(cmd);" +
                        "\n\t\t}\n");
            #endregion
            #region DeleteList
            sb.Append("\n\t\tpublic Boolean DeleteList(String lstID)" +
                        "\n\t\t{" +
                        "\n\t\t\tSqlCommand cmd = new SqlCommand(\"" + tbName + "_DeleteList\");" +
                        "\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;" +
                        "\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@lstID\", NullEx.getNullValue(lstID)));" +
                        "\n\t\t\treturn ExecuteNonQuery_RetBool(cmd);" +
                        "\n\t\t}\n");
            #endregion
            #region SelectItem
            sb.Append("\n\t\tpublic " + EntityObject + " SelectItem(" + EntityObject + " objInput)" +
                        "\n\t\t{" +
                        "\n\t\t\tSqlCommand cmd = new SqlCommand(\"" + tbName + "_SelectItem\");" +
                        "\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;");
            foreach (ColumnEO s in colName)
            {
                if (s.bPrimaryKey && !s.bTableAttack)
                    sb.Append("\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@" + s.sColumnName + "\", NullEx.getNullValue(objInput." + s.sColumnName + ")));");
            }
            sb.Append("\n\t\t\treturn " + tbName + "DO(GetDataTable(cmd));" +
                        "\n\t\t}\n");
            #endregion
            #region SelectList
            sb.Append("\n\t\tpublic DataTable SelectList()" +
                        "\n\t\t{" +
                        "\n\t\t\tSqlCommand cmd = new SqlCommand(\"" + tbName + "_SelectList\");" +
                        "\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;" +
                        "\n\t\t\treturn  GetDataTable(cmd);" +
                        "\n\t\t}\n");
            #endregion
            #region Select by foreignkey
            for (int i = 0; i < colName.Count; i++)
            {
                if ((colName[i].bForeignKey || colName[i].bPrimaryKey) && !colName[i].bTableAttack)
                {
                    sb.Append("\n\t\tpublic DataTable SelectBy_" + colName[i].sColumnName + "(" + EntityObject + " objInput)" +
                                "\n\t\t{" +
                                "\n\t\t\tSqlCommand cmd = new SqlCommand(\"" + tbName + "_SelectBy_" + colName[i].sColumnName + "\");" +
                                "\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;" +
                                "\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@" + colName[i].sColumnName + "\", NullEx.getNullValue(objInput." + colName[i].sColumnName + ")));" +
                                "\n\t\t\treturn GetDataTable(cmd);" +
                                "\n\t\t}\n");
                }
            }

            #endregion
            #region Dataset to Object
            sb.Append("\n\t\tpublic " + EntityObject + " " + tbName + "DO(DataTable dtInput)" +
                    "\n\t\t{" +
                    "\n\t\t\tList<" + EntityObject + "> lstTemp = new List<" + EntityObject + ">();" +
                    "\n\t\t\tlstTemp = (List<" + EntityObject + ">)ConvertEx.ConvertDataTableToListObject<" + EntityObject + ">(dtInput, lstTemp.GetType());" +
                    "\n\t\t\tif (CommonsCheck.ListObject_OK(lstTemp))" +
                    "\n\t\t\t\treturn lstTemp[0];" +
                        "\n\t\t\telse" +
                    "\n\t\t\t\treturn null;" +
                    "\n\t\t}");
            #endregion
            sb.Append("\n\t}" +
                "\n}");

            try
            {
                string link = System.Windows.Forms.Application.StartupPath + "\\" + Constants.FolderTemp.DataAccessObject + "\\" + DataAccessObject + ".cs";
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.DataAccessObject, DataAccessObject, Constants.FileExtension.DataAccessObject), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
            //#region Insert
            //listcolumn = "";
            //foreach (Column column in colName)
            //{
            //    if (!column.IsIdentity)
            //    {
            //        listcolumn += ConvertNew.ConvertDataTypeSQLtoCsharp(column.DataType) + " " + column.Name.ToString();
            //        if (k < colName.Count - 1)
            //            listcolumn += ",";
            //    }
            //    k++;
            //}
            //sb.Append("\n\t\tpublic static Boolean Insert(" + EntityObject + _EntityObject + ")" +
            //"\n\t\t{" +
            //"\n\t\t\tcmd = new SqlCommand(\"" + tbName + "_Insert\");" +
            //"\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;");
            //foreach (Column s in colName)
            //{
            //    if (!s.IsIdentity)
            //        sb.Append("\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@" + s.Name + "\"," + _EntityObject + "." + s.Name + "));");
            //}
            //sb.Append("\n\t\t\tExecuteNonQuery(cmd);" +
            //"\n\t\t\treturn true;" +
            //"\n\t\t}\n");
            //#endregion
            //#region Delete
            //sb.Append("\n\t\tpublic static Boolean Delete(string strID)" +
            //            "\n\t\t{" +
            //            "\n\t\t\tcmd = new SqlCommand(\"" + tbName + "_Delete\");" +
            //            "\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;" +
            //            "\n\t\t\tcmd.Parameters.Add(new SqlParameter(\"@strID\", strID));" +
            //            "\n\t\t\tExecuteNonQuery(cmd);" +
            //            "\n\t\t\treturn true;" +
            //            "\n\t\t}\n");
            //#endregion
        }

        public static void fncEntityObject(List<ColumnEO> colName, string tbName)
        {
            var sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace EntityObject" +
                        "\n{" +
                        "\n\t[Serializable()]" +
                        "\n\tpublic class " + EntityObject +
                        "\n\t{");
            foreach (ColumnEO item in colName)
            {
                sb.Append("\n\t\tprivate " + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + " _" + item.sColumnName + ";");
            }
            sb.Append("\n");

            foreach (ColumnEO item in colName)
            {
                sb.Append("\n\t\tpublic " + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + " " + item.sColumnName +
                "\n\t\t{" +
                "\n\t\t\tget { return this._" + item.sColumnName + "; }" +
                "\n\t\t\tset { this._" + item.sColumnName + " = value; }" +
                "\n\t\t}\n");
            }
            sb.Append("\t}\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.EntityObject, EntityObject, Constants.FileExtension.EntityObject), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncEntityObject_New(List<ColumnEO> colName, string tbName)
        {
            var sTemp1 = new StringBuilder();
            var sTemp2 = new StringBuilder();
            var sb = new StringBuilder();
            sb.Append("using System;" +
                "\nusing ThangNM_LIB.EO;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace EntityObject" +
                        "\n{" +
                        "\n\t[Serializable()]" +
                        "\n\tpublic class " + EntityObject + (isTableAttack ? " : SEOEO" : "") +
                        "\n\t{");
            foreach (ColumnEO item in colName)
            {
                if (!item.bTableAttack)
                {
                    string isnull = "";
                    sb.Append("\n\t\tpublic " + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + isnull + " " + item.sColumnName + " { get; set; }");
                    sTemp1.Append(", " + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + " _" + item.sColumnName);
                    sTemp2.Append("\n\t\t\tthis." + item.sColumnName + " = _" + item.sColumnName + ";");
                }
            }

            if (sTemp1 != null && sTemp1.ToString().Length > 2)
            {
                sb.Append("\n\n\t\tpublic " + EntityObject + "(" + sTemp1.ToString().Substring(2) + ")" +
                "\n\t\t{" +
                    sTemp2.ToString() +
                "\n\t\t}");
            }

            sb.Append("\n\n\t\tpublic " + EntityObject + "()" +
            "\n\t\t{" +
            "\n\t\t}\n");
            sb.Append("\t}\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.EntityObject, EntityObject, Constants.FileExtension.EntityObject), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncStoreProcedure(List<ColumnEO> colName, string tbName)
        {
            string dk;
            var sb = new StringBuilder();
            //sb.Append("USE [" + DatabaseName + "]\nGO\n");
            //sb.Append("IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[DBO].[" + tbName + "_CheckExists]') AND OBJECTPROPERTY(ID, N'IsProcedure') = 1)");
            //sb.Append("\nDROP PROCEDURE [DBO].[" + tbName + "_CheckExists]");
            //sb.Append("\nGO");
            sb.Append(String.Format(Constants.MS_SQL.CHECK_EXIST_PROCEDURE, DatabaseName, tbName + "_CheckExists", tbName + "_CheckExists"));
            sb.Append(Constants.MS_SQL.COMMENT_CODE_SQL);
            #region CheckExists
            sb.Append("\nCREATE PROCEDURE " + tbName + "_CheckExists" +
            "\n(");
            foreach (var item in colName)
            {
                if (item.bPrimaryKey && !item.bTableAttack)
                {
                    if (item.sSQL_DataType == "ntext" || item.sSQL_DataType == "text" || item.sSQL_DataType == "int" ||
                        item.sSQL_DataType == "tinyint" || item.sSQL_DataType == "bigint" || item.sSQL_DataType == "datetime" ||
                        item.sSQL_DataType == "smalldatetime" || item.sSQL_DataType == "money" || item.sSQL_DataType == "float" ||
                        item.sSQL_DataType == "real" || item.sSQL_DataType == "smallint" || item.sSQL_DataType == "decimal")
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + ",");
                    }
                    else if (item.sSQL_DataLength.ToString() == "-1")
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + "(MAX),");
                    }
                    else if (item.sSQL_DataType == "bit")
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + ",");
                    }
                    else
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + "(" + item.sSQL_DataLength + "),");
                    }
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\n)" +
            "\nAS" +
            "\nBEGIN" +
            "\n\tSET NOCOUNT ON;" +
            "\n\tIF EXISTS(SELECT 1 FROM " + tblFullName + " a");
            if (isTableAttack)
                sb.Append(" INNER JOIN tblSEO b ON (a." + colName[0].sColumnName + " = b.PK_iSID)");
            dk = "1=1";
            foreach (ColumnEO item in colName)
            {
                if (item.bPrimaryKey && !item.bTableAttack)
                    dk = dk + " AND (" + item.sColumnName + " = @" + item.sColumnName + ")";
            }
            dk = dk.Replace("1=1 AND", "");
            sb.Append(" WHERE " + dk +
            ")\n\t\tRETURN 1;" +
            "\n\tELSE" +
            "\n\t\tRETURN 0;" +
            "\nEND");
            #endregion

            //sb.Append("\nGO");
            //sb.Append("\nIF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[DBO].[" + tbName + "_Insert_Update_Delete]') AND OBJECTPROPERTY(ID, N'IsProcedure') = 1)");
            //sb.Append("\nDROP PROCEDURE [DBO].[" + tbName + "_Insert_Update_Delete]");
            //sb.Append("\nGO");
            sb.Append(String.Format(Constants.MS_SQL.CHECK_EXIST_PROCEDURE, DatabaseName, tbName + "_Insert_Update_Delete", tbName + "_Insert_Update_Delete"));
            sb.Append(Constants.MS_SQL.COMMENT_CODE_SQL);
            #region Insert_Update_Delete
            sb.Append("\nCREATE PROCEDURE " + tbName + "_Insert_Update_Delete" +
            "\n(");
            foreach (var item in colName)
            {
                if (item.sSQL_DataType == "ntext" || item.sSQL_DataType == "text" || item.sSQL_DataType == "int" ||
                    item.sSQL_DataType == "tinyint" || item.sSQL_DataType == "bigint" || item.sSQL_DataType == "datetime" ||
                    item.sSQL_DataType == "smalldatetime" || item.sSQL_DataType == "money" || item.sSQL_DataType == "float" ||
                    item.sSQL_DataType == "real" || item.sSQL_DataType == "smallint" || item.sSQL_DataType == "decimal")
                {
                    isAddOK = true;
                    sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + ",");
                }
                else if (item.sSQL_DataLength.ToString() == "-1")
                {
                    isAddOK = true;
                    sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + "(MAX),");
                }
                else if (item.sSQL_DataType == "bit")
                {
                    isAddOK = true;
                    sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + ",");
                }
                else
                {
                    isAddOK = true;
                    sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + "(" + item.sSQL_DataLength + "),");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append(",\n\t@Insert_Update_Delete SMALLINT");
            sb.Append("\n)" +
                "\nAS" +
                "\nBEGIN" +
                "\n\tDECLARE @errNumb INT, @errMsg VARCHAR(MAX)" +
                "\n\tSET XACT_ABORT ON" +
                "\n\tBEGIN TRANSACTION;" +
                "\n\tBEGIN TRY" +
                "\n\t\tIF @Insert_Update_Delete = 1" +
                "\n\t\tBEGIN" +
                "\n\t\t\tINSERT INTO " + tblFullName +
            "\n\t\t\t(");
            foreach (var item in colName)
            {
                if (!item.bIdentity && !item.bTableAttack)
                {
                    isAddOK = true;
                    sb.Append("\n\t\t\t\t" + item.sColumnName + ",");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\n\t\t\t)" +
            "\n\t\t\tVALUES" +
            "\n\t\t\t(");
            foreach (var item in colName)
            {
                if (!item.bIdentity && !item.bTableAttack)
                {
                    isAddOK = true;
                    sb.Append("\n\t\t\t\t@" + item.sColumnName + ",");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\n\t\t\t)");
            if (isTableAttack)
            {
                sb.Append("\n\n\t\t\tINSERT INTO tblSEO" +
            "\n\t\t\t(");
                foreach (var item in colName)
                {
                    if (!item.bIdentity && item.bTableAttack)
                    {
                        isAddOK = true;
                        sb.Append("\n\t\t\t\t" + item.sColumnName + ",");
                    }
                }
                if (isAddOK)
                {
                    isAddOK = false;
                    sb.Remove(sb.Length - 1, 1);
                }
                sb.Append("\n\t\t\t)" +
                "\n\t\t\tVALUES" +
                "\n\t\t\t(");
                foreach (var item in colName)
                {
                    if (!item.bIdentity && item.bTableAttack)
                    {
                        isAddOK = true;
                        sb.Append("\n\t\t\t\t@" + item.sColumnName + ",");
                    }
                }
                if (isAddOK)
                {
                    isAddOK = false;
                    sb.Remove(sb.Length - 1, 1);
                }
                sb.Append("\n\t\t\t)");
            }
            sb.Append("\n\t\tEND" +
                "\n\t\tELSE IF @Insert_Update_Delete = 2" +
                "\n\t\tBEGIN" +
                "\n\t\t\tUPDATE " + tblFullName +
                "\n\t\t\tSET");
            foreach (var item in colName)
            {
                if (!item.bIdentity && !item.bTableAttack)
                {
                    isAddOK = true;
                    sb.Append("\n\t\t\t\t" + item.sColumnName + " = @" + item.sColumnName + ",");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            dk = "1=1";
            foreach (ColumnEO item in colName)
            {
                if (item.bPrimaryKey && !item.bTableAttack)
                    dk = dk + "AND (" + item.sColumnName + " = @" + item.sColumnName + ")\n\t\t\t";
            }
            dk = dk.Replace("1=1AND ", "");
            sb.Append("\n\t\t\tWHERE " + dk.Trim());
            if (isTableAttack)
            {
                sb.Append("\n\n\t\t\tUPDATE tblSEO" +
                    "\n\t\t\tSET");
                foreach (var item in colName)
                {
                    if (!item.bIdentity && item.bTableAttack)
                    {
                        isAddOK = true;
                        sb.Append("\n\t\t\t\t" + item.sColumnName + " = @" + item.sColumnName + ",");
                    }
                }
                if (isAddOK)
                {
                    isAddOK = false;
                    sb.Remove(sb.Length - 1, 1);
                }
                dk = "1=1";
                foreach (ColumnEO item in colName)
                {
                    if (item.bPrimaryKey && item.bTableAttack)
                        dk = dk + "AND (" + item.sColumnName + " = @" + item.sColumnName + ")\n\t\t\t";
                }
                dk = dk.Replace("1=1AND ", "");
                sb.Append("\n\t\t\tWHERE " + dk.Trim());
            }
            sb.Append("\n\t\tEND" +
                "\n\t\tELSE IF @Insert_Update_Delete = 3" +
                "\n\t\tBEGIN" +
                "\n\t\t\tDELETE FROM " + tblFullName);
            dk = "1=1";
            foreach (ColumnEO item in colName)
            {
                if (item.bPrimaryKey && !item.bTableAttack)
                    dk = dk + "AND (" + item.sColumnName + " = @" + item.sColumnName + ")\n\t\t\t";
            }
            dk = dk.Replace("1=1AND", "");
            sb.Append("\n\t\t\tWHERE " + dk.Trim());
            if (isTableAttack)
            {
                sb.Append("\n\n\t\t\tDELETE FROM tblSEO");
                dk = "1=1";
                foreach (ColumnEO item in colName)
                {
                    if (item.bPrimaryKey && item.bTableAttack)
                        dk = dk + "AND (" + item.sColumnName + " = @" + item.sColumnName + ")\n\t\t\t";
                }
                dk = dk.Replace("1=1AND", "");
                sb.Append("\n\t\t\tWHERE " + dk.Trim());
            }
            sb.Append("\n\t\tEND");
            sb.Append("\n\t\tCOMMIT TRANSACTION;" +
            "\n\tEND TRY" +
            "\n\tBEGIN CATCH" +
            "\n\t\tROLLBACK TRANSACTION;" +
            "\n\t\tSET @errNumb = ERROR_NUMBER()" +
            "\n\t\tSET @errMsg = ERROR_MESSAGE() + '-' + ERROR_SEVERITY() + '-' + ERROR_STATE() + '-' + ERROR_PROCEDURE() + '-' + ERROR_LINE()" +
            "\n\t\tRAISERROR ('%d - %s', 16, 1111, @errNumb, @errMsg) " +
            "\n\tEND CATCH;" +
            "\nEND");
            #endregion


            //sb.Append("\nGO");
            //sb.Append("\nIF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[DBO].[" + tbName + "_DeleteList]') AND OBJECTPROPERTY(ID, N'IsProcedure') = 1)");
            //sb.Append("\nDROP PROCEDURE [DBO].[" + tbName + "_DeleteList]");
            //sb.Append("\nGO");
            sb.Append(String.Format(Constants.MS_SQL.CHECK_EXIST_PROCEDURE, DatabaseName, tbName + "_DeleteList", tbName + "_Insert_Update_Delete"));
            sb.Append(Constants.MS_SQL.COMMENT_CODE_SQL);
            #region DeleteList
            sb.Append("\nCREATE PROCEDURE " + tbName + "_DeleteList" +
            "\n(" +
            "\n\t@lstID NVARCHAR(2000)" +
            "\n)" +
            "\nAS" +
            "\nBEGIN" +
            "\n\tDECLARE @errNumb INT, @errMsg VARCHAR(MAX)" +
            "\n\tSET XACT_ABORT ON" +
            "\n\tBEGIN TRANSACTION;" +
            "\n\tBEGIN TRY" +
            "\n\t\tDELETE FROM " + tblFullName +
            "\n\t\tWHERE " + colName[0].sColumnName + " IN" +
            "\n\t\t(" +
            "\n\t\t\tSELECT CAST(Item AS BIGINT)" +
            "\n\t\t\tFROM dbo.SplitString(@lstID, ',', 1, 1)" +
            "\n\t\t)");
            if (isTableAttack)
            {
                sb.Append("\n\n\t\tDELETE FROM tblSEO" +
                "\n\t\tWHERE PK_iSID IN" +
                "\n\t\t(" +
                "\n\t\t\tSELECT CAST(Item AS BIGINT)" +
                "\n\t\t\tFROM dbo.SplitString(@lstID, ',', 1, 1)" +
                "\n\t\t)");
            }
            sb.Append("\n\t\tCOMMIT TRANSACTION;" +
            "\n\tEND TRY" +
            "\n\tBEGIN CATCH" +
            "\n\t\tROLLBACK TRANSACTION;" +
            "\n\t\tSET @errNumb = ERROR_NUMBER()" +
            "\n\t\tSET @errMsg = ERROR_MESSAGE() + '-' + ERROR_SEVERITY() + '-' + ERROR_STATE() + '-' + ERROR_PROCEDURE() + '-' + ERROR_LINE()" +
            "\n\t\tRAISERROR ('%d - %s', 16, 1111, @errNumb, @errMsg) " +
            "\n\tEND CATCH;" +
            "\nEND");
            #endregion

            //sb.Append("\nGO");
            //sb.Append("\nIF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[DBO].[" + tbName + "_SelectList]') AND OBJECTPROPERTY(ID, N'IsProcedure') = 1)");
            //sb.Append("\nDROP PROCEDURE [DBO].[" + tbName + "_SelectList]");
            //sb.Append("\nGO");
            sb.Append(String.Format(Constants.MS_SQL.CHECK_EXIST_PROCEDURE, DatabaseName, tbName + "_SelectList", tbName + "_SelectList"));
            sb.Append(Constants.MS_SQL.COMMENT_CODE_SQL);
            #region SelectList
            sb.Append("\nCREATE PROCEDURE " + tbName + "_SelectList" +
                "\nAS" +
                "\nBEGIN" +
                "\n\tSET NOCOUNT ON;" +
                "\n\tSELECT");
            foreach (var item in colName)
            {
                if (!item.bTableAttack)
                {
                    isAddOK = true;
                    sb.Append("\n\t\ta." + item.sColumnName + ",");
                }
                else
                {
                    isAddOK = true;
                    sb.Append("\n\t\tb." + item.sColumnName + ",");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\n\tFROM " + tblFullName + " a");
            if (isTableAttack)
                sb.Append(" INNER JOIN tblSEO b ON (a." + colName[0].sColumnName + " = b.PK_iSID)");
            sb.Append("\nEND");
            #endregion
            //sb.Append("\nGO");
            //sb.Append("\nIF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[DBO].[" + tbName + "_SelectItem]') AND OBJECTPROPERTY(ID, N'IsProcedure') = 1)");
            //sb.Append("\nDROP PROCEDURE [DBO].[" + tbName + "_SelectItem]");
            //sb.Append("\nGO");
            sb.Append(String.Format(Constants.MS_SQL.CHECK_EXIST_PROCEDURE, DatabaseName, tbName + "_SelectItem", tbName + "_SelectItem"));
            sb.Append(Constants.MS_SQL.COMMENT_CODE_SQL);
            #region SelectItem
            sb.Append("\nCREATE PROCEDURE " + tbName + "_SelectItem" +
            "\n(");
            foreach (var item in colName)
            {
                if (item.bPrimaryKey && !item.bTableAttack)
                {
                    if (item.sSQL_DataType == "ntext" || item.sSQL_DataType == "text" || item.sSQL_DataType == "int" ||
                        item.sSQL_DataType == "tinyint" || item.sSQL_DataType == "bigint" || item.sSQL_DataType == "datetime" ||
                        item.sSQL_DataType == "smalldatetime" || item.sSQL_DataType == "money" || item.sSQL_DataType == "float" ||
                        item.sSQL_DataType == "real" || item.sSQL_DataType == "smallint" || item.sSQL_DataType == "decimal")
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + ",");
                    }
                    else if (item.sSQL_DataLength.ToString() == "-1")
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + "(MAX),");
                    }
                    else if (item.sSQL_DataType == "bit")
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + ",");
                    }
                    else
                    {
                        isAddOK = true;
                        sb.Append("\n\t@" + item.sColumnName + " " + item.sSQL_DataType.ToUpper() + "(" + item.sSQL_DataLength + "),");
                    }
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\n)" +
            "\nAS" +
            "\nBEGIN" +
            "\n\tSET NOCOUNT ON;" +
            "\n\tSELECT a.*");
            if (isTableAttack)
                sb.Append(", b.*");
            sb.Append("\n\tFROM " + tblFullName + " a");
            if (isTableAttack)
                sb.Append(" INNER JOIN tblSEO b ON (a." + colName[0].sColumnName + " = b.PK_iSID)");
            dk = "1=1";
            foreach (ColumnEO item in colName)
            {
                if (item.bPrimaryKey && !item.bTableAttack)
                {
                    isAddOK = true;
                    dk = dk + "AND (" + item.sColumnName + " = @" + item.sColumnName + ")\n\t\t";
                }
            }
            dk = dk.Replace("1=1AND", "");
            sb.Append("\n\tWHERE " + dk);
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 2, 2);
            }
            sb.Append("END");
            #endregion

            //sb.Append("\nGO");
            #region SelectBy_Foreignkey
            for (int i = 0; i < colName.Count; i++)
            {
                if ((colName[i].bForeignKey || colName[i].bPrimaryKey) && !colName[i].bTableAttack)
                {
                    //sb.Append("\nIF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[DBO].[" + tbName + "_SelectBy_" + colName[i].sColumnName + "]') AND OBJECTPROPERTY(ID, N'IsProcedure') = 1)");
                    //sb.Append("\nDROP PROCEDURE [DBO].[" + tbName + "_SelectBy_" + colName[i].sColumnName + "]");
                    //sb.Append("\nGO");
                    sb.Append(String.Format(Constants.MS_SQL.CHECK_EXIST_PROCEDURE, DatabaseName, tbName + "_SelectBy_" + colName[i].sColumnName, tbName + "_SelectBy_" + colName[i].sColumnName));
                    sb.Append(Constants.MS_SQL.COMMENT_CODE_SQL);
                    sb.Append("\nCREATE PROCEDURE " + tbName + "_SelectBy_" + colName[i].sColumnName +
                    "\n(");
                    if (colName[i].sSQL_DataType == "ntext" || colName[i].sSQL_DataType == "text" || colName[i].sSQL_DataType == "int" ||
                        colName[i].sSQL_DataType == "tinyint" || colName[i].sSQL_DataType == "bigint" || colName[i].sSQL_DataType == "datetime" ||
                        colName[i].sSQL_DataType == "smalldatetime" || colName[i].sSQL_DataType == "money" || colName[i].sSQL_DataType == "float" ||
                        colName[i].sSQL_DataType == "real" || colName[i].sSQL_DataType == "smallint")
                        sb.Append("\n\t@" + colName[i].sColumnName + " " + colName[i].sSQL_DataType.ToUpper());
                    else if (colName[0].sSQL_DataLength.ToString() == "-1")
                        sb.Append("\n\t@" + colName[i].sColumnName + " " + colName[i].sSQL_DataType.ToUpper() + "(MAX)");
                    else if (colName[0].sSQL_DataType.ToString() == "bit")
                        sb.Append("\n\t@" + colName[i].sColumnName + " " + colName[i].sSQL_DataType.ToUpper());
                    else sb.Append("\n\t@" + colName[i].sColumnName + " " + colName[i].sSQL_DataType.ToUpper() + "(" + colName[i].sSQL_DataLength + ")");
                    sb.Append("\n)" +
                    "\nAS" +
                    "\nBEGIN" +
                    "\n\tSET NOCOUNT ON;" +
                    "\n\tSELECT ");
                    foreach (var item in colName)
                    {
                        if (!item.bTableAttack)
                        {
                            isAddOK = true;
                            sb.Append("\n\t\ta." + item.sColumnName + ",");
                        }
                        else
                        {
                            isAddOK = true;
                            sb.Append("\n\t\tb." + item.sColumnName + ",");
                        }
                    }
                    if (isAddOK)
                    {
                        isAddOK = false;
                        sb.Remove(sb.Length - 1, 1);
                    }
                    sb.Append("\n\tFROM " + tblFullName + " a");
                    if (isTableAttack)
                        sb.Append(" INNER JOIN tblSEO b ON (a." + colName[0].sColumnName + " = b.PK_iSID)");
                    sb.Append("\n\tWHERE (" + colName[i].sColumnName + "=@" + colName[i].sColumnName + ")" +
                    "\nEND" +
                    "\nGO");
                }
            }
            #endregion
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.StoreProcedure, tbName, Constants.FileExtension.StoreProcedure), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAspx(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"" + UI + ".aspx.cs\" Inherits=\"" + Constants.Information.ProjectName + ".Admin." + UI + "\" MasterPageFile=\"~/PublicInterface/Admin.Master\" %>" +
                        "\n<%@ Register src=\"../UserControl/" + _ListUC + ".ascx\" tagname=\"" + _ListUC + "\" tagprefix=\"uc1\" %>" +
                        "\n<%@ Register src=\"../UserControl/" + _DetailUC + ".ascx\" tagname=\"" + _DetailUC + "\" tagprefix=\"uc2\" %>" +
                        "\n<%@ Register src=\"../UserControl/MsgUC.ascx\" tagname=\"MsgUC\" tagprefix=\"uc3\" %>" +
                        "\n<%@ Register src=\"../UserControl/Title_FormUC.ascx\" tagname=\"Title_FormUC\" tagprefix=\"uc4\" %>" +
                        "\n" +
                        "\n<asp:Content ID=\"cBody\" runat=\"server\" ContentPlaceHolderID=\"cphBody\">" +
                            "\n\t<uc4:Title_FormUC ID=\"Title_FormUC1\" runat=\"server\" />" +
                            "\n\t<uc3:MsgUC ID=\"MsgUC1\" runat=\"server\" />" +
                            "\n\t<asp:MultiView ID=\"mtvMain\" runat=\"server\" ActiveViewIndex=\"0\">" +
                                "\n\t\t<asp:View ID=\"vList\" runat=\"server\">" +
                                    "\n\t\t\t<uc1:" + _ListUC + " ID=\"" + _ListUC1 + "\" runat=\"server\" OnViewDetail=\"ViewDetail_Click\" OnInsert=\"Insert_Click\" OnViewMessage=\"ViewMessageList_Click\" />" +
                                "\n\t\t</asp:View>" +
                                "\n\t\t<asp:View ID=\"vDetail\" runat=\"server\">" +
                                    "\n\t\t\t<asp:LinkButton ID=\"lbtnBack\" runat=\"server\" onclick=\"lbtnBack_Click\" CssClass=\"btn btn-info btn-sm\">" +
                                    "\n\t\t\t\t<i class=\"fa fa-mail-reply-all\"></i> Quay lại danh sách" +
                                    "\n\t\t\t</asp:LinkButton><br /><br />" +
                                    "\n\t\t\t<uc2:" + _DetailUC + " ID=\"" + _DetailUC1 + "\" runat=\"server\" OnViewMessage=\"ViewMessageDetail_Click\"/>" +
                                "\n\t\t</asp:View>" +
                            "\n\t</asp:MultiView>" +
                        "\n</asp:Content>\n");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_Admin, tbName, Constants.FileExtension.Aspx), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAspxCs(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web;" +
                        "\nusing System.Web.UI;" +
                        "\nusing System.Web.UI.WebControls;" +
                        "\nusing SharedLibraries;" +
                        "\nusing EntityObject;" +
                        "\nusing SharedLibraries.Constants;" +
                        "\nusing DataAccessObject;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\n" +
                        "\nnamespace " + Constants.Information.ProjectName + ".Admin" +
                        "\n{" +
                            "\n\tpublic partial class " + UI + " : System.Web.UI.Page" +
                            "\n\t{" +
                                "\n\t\tprotected void Page_Load(object sender, EventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tMsgUC1.setClearMsg();" +
                                    "\n\t\t\tif (!IsPostBack)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tTitle_FormUC1.setTitle(Table_Name_C." + tbName + ", MutilView_C.LIST);" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tpublic override void VerifyRenderingInServerForm(Control control)" +
                                "\n\t\t{" +
                                 "\n\t\t\t/* Verifies that the control is rendered */" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\t#region \"Raise Event\"" +
                                "\n\t\tprotected void ViewDetail_Click(object sender, CustomerEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tmtvMain.SetActiveView(vDetail);" +
                                    "\n\t\t\t" + _DetailUC1 + ".BindDataDetail((" + EntityObject + ")e.objEntity,FunctionType.View);" +
                                    "\n\t\t\tTitle_FormUC1.setTitle(Table_Name_C." + tbName + ", MutilView_C.DETAIL);" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void Notification_Click(object sender, CustomerEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tMsgUC1.setNotifications(FunctionSetMsg.INFO, e.sMessage);" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void Insert_Click(object sender, EventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tmtvMain.SetActiveView(vDetail);" +
                                    "\n\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                                    "\n\t\t\t" + _DetailUC1 + ".BindDataDetail(" + _EntityObject + ", FunctionType.Insert);" +
                                    "\n\t\t\tTitle_FormUC1.setTitle(Table_Name_C." + tbName + ", MutilView_C.INSERT);" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void ViewMessageList_Click(object sender, CustomerEventArgs e)" +
                                    "\n\t\t{" +
                                    "\n\t\t\tMsgUC1.setNotifications(e.iType, e.sMessage);" +
                                        "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void ViewMessageDetail_Click(object sender, CustomerEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tif (e.iType == FunctionSetMsg.SUCCESS)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tmtvMain.SetActiveView(vList);" +
                                        "\n\t\t\t\t" + _ListUC1 + ".ResetFormSearch();" +
                                        "\n\t\t\t\t" + _ListUC1 + ".BindData_List(null);" +
                                    "\n\t\t\t}" +
                                    "\n\t\t\tMsgUC1.setNotifications(e.iType, e.sMessage);" +
                                "\n\t\t}" +
                                "\n\t\t#endregion" +
                        "\n" +
                                "\n\t\tprotected void lbtnBack_Click(object sender, EventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tmtvMain.SetActiveView(vList);" +
                                    "\n\t\t\t" + _ListUC1 + ".ResetFormSearch();" +
                                    "\n\t\t\t" + _ListUC1 + ".BindData_List(null);" +
                                    "\n\t\t\tTitle_FormUC1.setTitle(Table_Name_C." + tbName + ", MutilView_C.LIST);" +
                                "\n\t\t}" +
                            "\n\t}" +
                        "\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_Admin, tbName, Constants.FileExtension.AspxCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAspxDesignerCs(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP_DESIGNER);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".Admin {" +
                        "\n" +
                            "\n\tpublic partial class " + UI + " {" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// Title_FormUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.Title_FormUC Title_FormUC1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// MsgUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.MsgUC MsgUC1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// mtvMain control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.MultiView mtvMain;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// vList control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.View vList;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// " + _ListUC1 + " control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl." + tbName + "_ListUC " + tbName + "_ListUC1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// vDetail control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.View vDetail;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// lbtnBack control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.LinkButton lbtnBack;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// " + _DetailUC1 + " control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl." + tbName + "_DetailUC " + _DetailUC1 + ";" +
                            "\n\t}" +
                        "\n}\n");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_Admin, tbName, Constants.FileExtension.AspxDesignerCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscx_List(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"" + _ListUC + ".ascx.cs\" Inherits=\"" + Constants.Information.ProjectName + ".UserControl." + _ListUC + "\" %>" +
                        "\n<%@ Register src=\"SearchUI.ascx\" tagname=\"SearchUI\" tagprefix=\"uc1\" %>" +
                        "\n<%@ Register src=\"ToolBarUC.ascx\" tagname=\"ToolBarUC\" tagprefix=\"uc2\" %>" +
                        "\n" +
                        "\n<script type=\"text/javascript\">" +
                            "\n\tfunction CheckAll(chkTemp) {" +
                                "\n\t\tvar grvTemp = document.getElementById(\"<%=grvList.ClientID %>\");" +
                                "\n\t\tfor (i = 1; i < grvTemp.rows.length; i++) {" +
                                    "\n\t\t\tgrvTemp.rows[i].cells[0].getElementsByTagName(\"INPUT\")[0].checked = chkTemp.checked;" +
                                "\n\t\t}" +
                            "\n\t}" +
                        "\n</script>" +
                        "\n<uc2:ToolBarUC ID=\"ToolBarUC1\" runat=\"server\" OnEventButtonToolBar=\"EventButtonToolBar_Click\" OnEventSelectChange=\"EventSelectChange_Click\"/>" +
                        "\n<table id=\"tblList\" style=\"border-collapse: collapse\" cellpadding=\"0\" width=\"100%\" border=\"0\">" +
                            "\n\t<tr>" +
                                "\n\t\t<td>" +
                                    "\n\t\t\t<uc1:SearchUI ID=\"SearchUI1\" runat=\"server\" OnSearch=\"Search_Click\" /><br />" +
                                "\n\t\t</td>" +
                            "\n\t</tr>" +
                            "\n\t<tr>" +
                                "\n\t\t<td>" +
                                    "\n\t\t\t<asp:GridView ID=\"grvList\" runat=\"server\" CssClass=\"table table-striped table-bordered table-hover dataTable no-footer\" AutoGenerateColumns=\"False\" AutoGenerateCheckBoxColumn=\"True\" " +
                                        "\n\t\t\t\tFileTypeDownload=\"Excel\" Width=\"100%\" AllowPaging=\"True\" datakeynames=\"" + colName[0].sColumnName + "\" " +
                                        "\n\t\t\t\temptydatatext=\"Không có bản ghi nào.\" onrowcommand=\"grvList_RowCommand\" " +
                                        "\n\t\t\t\tonpageindexchanging=\"grvList_PageIndexChanging\" PageSize=\"10\" AllowSorting=\"true\" onsorting=\"grvList_Sorting\">" +
                                        "\n\t\t\t\t<AlternatingRowStyle CssClass=\"GridAlternatingItem\"></AlternatingRowStyle>" +
                                        "\n\t\t\t\t<Columns>" +
                                            "\n\t\t\t\t\t<asp:TemplateField>" +
                                                "\n\t\t\t\t\t\t<HeaderTemplate>" +
                                                    "\n\t\t\t\t\t\t\t<input id=\"chkHead\" type=\"checkbox\" onclick=\"CheckAll(this)\" runat=\"server\" />" +
                                                "\n\t\t\t\t\t\t</HeaderTemplate>" +
                                                "\n\t\t\t\t\t\t<ItemTemplate>" +
                                                    "\n\t\t\t\t\t\t\t<asp:CheckBox ID=\"chkItem\" runat=\"server\" />" +
                                                "\n\t\t\t\t\t\t</ItemTemplate>" +
                                                "\n\t\t\t\t\t\t<ItemStyle HorizontalAlign=\"Center\" />" +
                                            "\n\t\t\t\t\t</asp:TemplateField>" +
                                            "\n\t\t\t\t\t<asp:TemplateField>" +
                                                "\n\t\t\t\t\t\t<ItemTemplate>" +
                                                    "\n\t\t\t\t\t\t\t<asp:LinkButton ID=\"cmdDetail\" runat=\"server\" CommandName=\"cmdView\" Width=\"90px\" CommandArgument='<%#Container.DataItemIndex %>'>Chi tiết</asp:LinkButton>" +
                                                "\n\t\t\t\t\t\t</ItemTemplate>" +
                                                "\n\t\t\t\t\t\t<ItemStyle HorizontalAlign=\"Center\" />" +
                                            "\n\t\t\t\t\t</asp:TemplateField>");
            for (int i = 0; i < colName.Count; i++)
            {
                sb.Append("\n\t\t\t\t\t<asp:BoundField  DataField=\"" + colName[i].sColumnName + "\"  HeaderText=\"" + colName[i].sColumnName + "\" SortExpression=\"" + colName[i].sColumnName + "\">" +
                    "\n\t\t\t\t\t\t<ItemStyle Wrap=\"true\" CssClass=\"GridItemNumber\"/>" +
                    "\n\t\t\t\t\t</asp:BoundField>");
            }
            sb.Append("\n\t\t\t\t</Columns>" +
            "\n\t\t\t\t<PagerStyle CssClass=\"numberpagestyle\" />" +
            "\n\t\t\t\t<HeaderStyle CssClass=\"headerpagestyle\" />" +
        "\n\t\t\t</asp:GridView>" +
    "\n\t\t</td>" +
"\n\t</tr>" +
"\n\t<tr>" +
    "\n\t\t<td>" +
        "\n\t\t\t<asp:Label id=\"lblRowCount\" runat=\"server\" ForeColor=\"Blue\"></asp:Label>" +
    "\n\t\t</td>" +
"\n\t</tr>" +
"\n</table>");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_List", Constants.FileExtension.Ascx), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxCs_List(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web;" +
                        "\nusing System.Web.UI;" +
                        "\nusing System.Web.UI.WebControls;" +
                        "\nusing EntityObject;" +
                        "\nusing System.Drawing;" +
                        "\nusing SharedLibraries;" +
                        "\nusing DataAccessObject;" +
                        "\nusing System.Data;" +
                        "\nusing System.IO;" +
                        "\nusing SharedLibraries.Constants;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl" +
                        "\n{" +
                            "\n\tpublic partial class " + _ListUC + " : System.Web.UI.UserControl" +
                            "\n\t{" +
                                "\n\t\t#region \"Properties & Event\"" +
                                    "\n\t\t\tpublic delegate void CustomerEventHandler(object sender, CustomerEventArgs args);" +
                                    "\n\t\t\tpublic event CustomerEventHandler ViewDetail;" +
                                    "\n\t\t\tpublic event CustomerEventHandler ViewMessage;" +
                                    "\n\t\t\tpublic event EventHandler Insert;" +
                                    "\n" +
                                    "\n\t\t\tpublic SortDirection directionState" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tget { return (ViewState[\"directionState\"]==null? SortDirection.Descending: (SortDirection)ViewState[\"directionState\"]); }" +
                                        "\n\t\t\t\tset { ViewState[\"directionState\"] = value; }" +
                                    "\n\t\t\t}" +
                                "\n\t\t#endregion" +
                        "\n" +
                                "\n\t\tprotected void Page_Load(object sender, EventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tif (!IsPostBack)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tToolBarUC1.ViewGroupButtonByFunction(FunctionListDetail.LIST);" +
                                        "\n\t\t\t\tToolBarUC1.BindData_DropDownList(GetListConstants.Category_iStatus_GLC());" +
                                        "\n\t\t\t\tToolBarUC1.SetDefaultValue(1);" +
                                        "\n\t\t\t\tBindData_List(null);" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                                "\n" +
                                "\n\t\tpublic void BindData_List(String sSortColumn)" +
                                "\n\t\t{" +
                                    "\n\t\t\ttry" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tList<" + EntityObject + "> lst = new List<" + EntityObject + ">();" +
                                        "\n\t\t\t\tgrvList.Visible = false;" +
                                        "\n\t\t\t\tstring keysearch = Commons.Trim(SearchUI1.txtTextSearch.Text).ToUpper();" +
                                        "\n\t\t\t\tDataTable dt = " + DataAccessObject + ".SelectList(ToolBarUC1.ddlStatus.SelectedValue);" +
                                        "\n\t\t\t\tDataView dv = dt.DefaultView;" +
                                        "\n\t\t\t\tif (!String.IsNullOrEmpty(sSortColumn))" +
                                            "\n\t\t\t\t\tdv.Sort = sSortColumn;" +
                                        "\n\t\t\t\telse" +
                                            "\n\t\t\t\t\tdv.Sort = \"[" + colName[0].sColumnName + "] DESC\";" +
                                        "\n\t\t\t\tdt = dv.ToTable();" +
                                        "\n\t\t\t\tvar result = (List<" + EntityObject + ">)Commons.ConvertDataTableToListObject<" + EntityObject + ">(dt, lst.GetType());" +
                                        "\n\t\t\t\tif (CommonsCheck.ListObject_OK(result))" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tif (SearchUI1.ddlTypeSearch.SelectedValue.Equals(\"0\"))" +
                                                "\n\t\t\t\t\t\tif (!String.IsNullOrEmpty(keysearch))" +
                                                    "\n\t\t\t\t\t\tresult = result.FindAll(x => Commons.Trim(x." + colName[0].sColumnName + ".ToString()).ToUpper().Contains(keysearch));" +
                                            "\n\t\t\t\t\telse" +
                                                "\n\t\t\t\t\t\tif (!String.IsNullOrEmpty(keysearch))" +
                                                    "\n\t\t\t\t\t\tresult = result.FindAll(x => Commons.Trim(x." + colName[1].sColumnName + ".ToString()).ToUpper().Contains(keysearch));" +
                                            "\n\t\t\t\t\tif (result.Count() > 0)" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tgrvList.Visible = true;" +
                                                "\n\t\t\t\t\t\tgrvList.DataSource = result.ToList();" +
                                                "\n\t\t\t\t\t\tgrvList.DataBind();" +
                                                "\n\t\t\t\t\t\tlblRowCount.Text = Messages.Tong_So_Ban_Ghi + result.Count();" +
                                                "\n\t\t\t\t\t\treturn;" +
                                            "\n\t\t\t\t\t}" +
                                        "\n\t\t\t\t}" +
                                        "\n\t\t\t\tgrvList.DataSource = null;" +
                                        "\n\t\t\t\tgrvList.DataBind();" +
                                        "\n\t\t\t\tlblRowCount.Text = Messages.Khong_Thoa_Man_Dieu_Kien_Tim_Kiem;" +
                                    "\n\t\t\t}" +
                                    "\n\t\t\tcatch (Exception ex)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (ViewMessage != null)" +
                                            "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.ERROR, ex.Message, null));" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tpublic void ResetFormSearch()" +
                                "\n\t\t{" +
                                    "\n\t\t\tSearchUI1.txtTextSearch.Text = \"\";" +
                                    "\n\t\t\tSearchUI1.ddlTypeSearch.SelectedValue = \"0\";" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\t#region \"Event Handler\"" +
                                "\n\t\tprotected void Search_Click(object sender, EventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tBindData_List(null);" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void EventSelectChange_Click(object sender, CustomerEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tif (e != null)" +
                                        "\n\t\t\t\tBindData_List(null);" +
                                "\n\t\t}" +
                                "\n" +
                                "\n\t\tprotected void EventButtonToolBar_Click(object sender, CustomerEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tswitch (e.iType)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tcase funcButtonToolBar.INSERT_LIST:" +
                                            "\n\t\t\t\t\tif (Insert != null)" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tInsert(this, EventArgs.Empty);" +
                                            "\n\t\t\t\t\t}" +
                                            "\n\t\t\t\t\tbreak;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.INSERT_ITEM:break;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.UPDATE_ITEM:break;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.DELETE_LIST:" +
                                            "\n\t\t\t\t\tDeleteList();" +
                                            "\n\t\t\t\t\tbreak;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.DELETE_ITEM:break;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.REFRESH_LIST:" +
                                            "\n\t\t\t\t\tResetFormSearch();" +
                                            "\n\t\t\t\t\tBindData_List(null);" +
                                            "\n\t\t\t\t\tbreak;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.EXPORT_EXCEL:" +
                                            "\n\t\t\t\t\tif (grvList.PageCount > 0)" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tExport_Lib.PDF_Export(grvList, \"" + tbName + "\");" +
                                            "\n\t\t\t\t\t}" +
                                            "\n\t\t\t\t\telse" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tif (ViewMessage != null)" +
                                                    "\n\t\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.WARNING, \"Không thể xuất file vì không có bản ghi nào.\", null));" +
                                            "\n\t\t\t\t\t}" +
                                            "\n\t\t\t\t\tbreak;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.RESET_FORM:break;" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                                "\n\t\t#endregion" +
                        "\n" +
                                "\n\t\t#region \"Event GridView\"" +
                                "\n\t\tprotected void grvList_RowCommand(object source, GridViewCommandEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tif (e.CommandName == \"cmdView\")" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tint rowIndex = Convert.ToInt32(e.CommandArgument) % grvList.PageSize;" +
                                        "\n\t\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +

                                        "\n\t\t\t\t" + _EntityObject + "." + colName[0].sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(colName[0]) + "(grvList.DataKeys[rowIndex].Values[0]);" +
                                        "\n\t\t\t\t" + _EntityObject + " = " + DataAccessObject + ".SelectItem(" + _EntityObject + ");" +
                                        "\n\t\t\t\tif (ViewDetail != null)" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tViewDetail(this, new CustomerEventArgs(1, \"Oki\"," + _EntityObject + "));" +
                                        "\n\t\t\t\t}" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void grvList_PageIndexChanging(object sender, GridViewPageEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tgrvList.PageIndex = e.NewPageIndex;" +
                                    "\n\t\t\tBindData_List(null);" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void grvList_Sorting(object sender, GridViewSortEventArgs e)" +
                                "\n\t\t{" +
                                        "\n\t\t\tif (directionState == SortDirection.Ascending)" +
                                        "\n\t\t\t{" +
                                            "\n\t\t\t\tdirectionState = SortDirection.Descending;" +
                                            "\n\t\t\t\tBindData_List(\"[\" + e.SortExpression + \"]\" + \" DESC\");" +
                                        "\n\t\t\t}" +
                                        "\n\t\t\telse" +
                                        "\n\t\t\t{" +
                                            "\n\t\t\t\tdirectionState = SortDirection.Ascending;" +
                                            "\n\t\t\t\tBindData_List(\"[\" + e.SortExpression +\"]\" + \" ASC\");" +
                                        "\n\t\t\t}" +
                                "\n\t\t}" +
                                "\n\t\t#endregion" +
                        "\n" +
                                "\n\t\tprotected void DeleteList()" +
                                "\n\t\t{" +
                                    "\n\t\t\ttry" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tstring strID = \"\";" +
                                        "\n\t\t\t\tforeach (GridViewRow row in grvList.Rows)" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tCheckBox chk = (CheckBox)row.FindControl(\"chkItem\");" +
                                            "\n\t\t\t\t\tif (chk != null && chk.Checked)" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tstrID += \",\" + grvList.DataKeys[row.RowIndex].Values[\"" + colName[0].sColumnName + "\"];" +
                                            "\n\t\t\t\t\t}" +
                                        "\n\t\t\t\t}" +
                                        "\n\t\t\t\tif (String.IsNullOrEmpty(strID))" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tif (ViewMessage != null)" +
                                                "\n\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.WARNING, String.Format(Messages.CHUA_CHON_DONG_NAO_DE_XOA, Table_Name_C." + tbName + "), null));" +
                                            "\n\t\t\t\t\treturn;" +
                                        "\n\t\t\t\t}" +
                                        "\n\t\t\t\tif (" + DataAccessObject + ".Delete(strID.Substring(1)))" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tBindData_List(null);" +
                                            "\n\t\t\t\t\tif (ViewMessage != null)" +
                                                "\n\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.SUCCESS, String.Format(Messages.Xoa_Thanh_Cong_Ma, Table_Name_C." + tbName + ", strID.Substring(1)), null));" +
                                        "\n\t\t\t\t}" +
                                        "\n\t\t\t\telse" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tif (ViewMessage != null)" +
                                                "\n\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.WARNING, String.Format(Messages.Xoa_That_Bai_Ma, Table_Name_C." + tbName + ", strID.Substring(1)), null));" +
                                        "\n\t\t\t\t}" +
                                    "\n\t\t\t}" +
                                    "\n\t\t\tcatch (Exception ex)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (ViewMessage != null)" +
                                            "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.ERROR, ex.Message, null));" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                            "\n\t}" +
                        "\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_List", Constants.FileExtension.AscxCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxDesignerCs_List(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP_DESIGNER);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl {" +
                        "\n" +
                            "\n\tpublic partial class " + _ListUC + " {" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// ToolBarUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.ToolBarUC ToolBarUC1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// SearchUI1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.SearchUI SearchUI1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// grvList control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.GridView grvList;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// lblRowCount control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.Label lblRowCount;" +
                            "\n\t}" +
                        "\n}\n");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_List", Constants.FileExtension.AscxDesignerCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscx_Detail(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"" + _DetailUC + ".ascx.cs\" Inherits=\"" + Constants.Information.ProjectName + ".UserControl." + _DetailUC + "\" %>" +
                    "\n<%@ Register src=\"ToolBarUC.ascx\" tagname=\"ToolBarUC\" tagprefix=\"uc1\" %>" +
                    "\n" +
                    "\n<table id=\"tblDetail\" class=\"form-group\">");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    sb.Append("\n\t<tr>" +
                           "\n\t\t<td>" +
                               "\n\t\t\t<div class=\"form-group input-group\">" +
                                   "\n\t\t\t\t<asp:Label id=\"lbl" + colName[i].sColumnName + "\" runat=\"server\" CssClass=\"input-group-addon title_input\" Text=\"" + colName[i].sColumnName + ":\"></asp:Label>" +
                                   "\n\t\t\t\t<asp:TextBox id=\"txt" + colName[i].sColumnName + "\" runat=\"server\" Width=\"500px\" CssClass=\"form-control\"></asp:TextBox>" +
                                   "\n\t\t\t\t<span class=\"notnull\">(* Bắt buộc)</span>" +
                               "\n\t\t\t</div>" +
                           "\n\t\t</td>" +
                       "\n\t</tr>");
                }
                else
                {
                    sb.Append("\n\t<tr>" +
                           "\n\t\t<td>" +
                               "\n\t\t\t<div class=\"form-group input-group\">" +
                                   "\n\t\t\t\t<asp:Label id=\"lbl" + colName[i].sColumnName + "\" runat=\"server\" CssClass=\"input-group-addon title_input\" Text=\"" + colName[i].sColumnName + ":\"></asp:Label>" +
                                   "\n\t\t\t\t<asp:DropDownList id=\"ddl" + colName[i].sColumnName + "\" runat=\"server\" Width=\"500px\" CssClass=\"form-control\"></asp:DropDownList>" +
                                   "\n\t\t\t\t<span class=\"notnull\">(* Bắt buộc)</span>" +
                               "\n\t\t\t</div>" +
                           "\n\t\t</td>" +
                       "\n\t</tr>");
                }
            }
            sb.Append("\n\t<tr>" +
                "\n\t\t<td>" +
                    "\n\t\t\t<uc1:ToolBarUC ID=\"ToolBarUC1\" runat=\"server\" OnEventButtonToolBar=\"EventButtonToolBar_Click\" />" +
                "\n\t\t</td>" +
            "\n\t</tr>" +
        "\n</table><br /><br /><br /><br />");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_Detail", Constants.FileExtension.Ascx), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxCs_Detail(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web;" +
                        "\nusing System.Web.UI;" +
                        "\nusing System.Web.UI.WebControls;" +
                        "\nusing EntityObject;" +
                        "\nusing SharedLibraries;" +
                        "\nusing DataAccessObject;" +
                        "\nusing SharedLibraries.Constants;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl" +
                        "\n{" +
                            "\n\tpublic partial class " + _DetailUC + " : System.Web.UI.UserControl" +
                            "\n\t{" +
                                "\n\t\t#region \"Properties & Event\"" +
                                "\n\t\tpublic delegate void CustomerEventHandler(object sender, CustomerEventArgs args);" +
                                "\n\t\tpublic event CustomerEventHandler ViewMessage;" +
                        "\n" +
                                "\n\t\tpublic Int16 iFunctionType" +
                                "\n\t\t{" +
                                    "\n\t\t\tget { return (Int16)ViewState[\"iFunctionType\"]; }" +
                                    "\n\t\t\tset { ViewState[\"iFunctionType\"] = value; }" +
                                "\n\t\t}" +
                                "\n" +
                                "\n\t\tpublic" + EntityObject + objEntityObject + "_Temp" +
                                "\n\t\t{" +
                                    "\n\t\t\tget { return (" + EntityObject + ")ViewState[\"" + objEntityObject + "_Temp\"]; }" +
                                    "\n\t\t\tset { ViewState[\"" + objEntityObject + "_Temp\"] = value; }" +
                                "\n\t\t}" +
                                "\n\t\t#endregion" +
                        "\n" +
                                "\n\t\tprotected void Page_Load(object sender, EventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\ttry" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (!IsPostBack)" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tToolBarUC1.ViewGroupButtonByFunction(FunctionListDetail.DETAIL);" +
                                            "\n\t\t\t\t\tBindData_DropDownList();" +
                                        "\n\t\t\t\t}" +
                                    "\n\t\t\t}" +
                                    "\n\t\t\tcatch (Exception ex)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (ViewMessage != null)" +
                                            "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.ERROR, ex.Message, null));" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tpublic void BindDataDetail(" + EntityObject + _EntityObject + ", Int16 iFuncType)" +
                                "\n\t\t{" +
                                "\n\t\t\t" + objEntityObject + "_Temp = " + _EntityObject + ";");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    sb.Append("\n\t\t\ttxt" + colName[i].sColumnName + ".Text = Convert.ToString(" + _EntityObject + "." + colName[i].sColumnName + ");");
                }
                else
                {
                    sb.Append("\n\t\t\tddl" + colName[i].sColumnName + ".SelectedValue = Convert.ToString(" + _EntityObject + "." + colName[i].sColumnName + ");");
                }
            }

            sb.Append("\n\t\t\tiFunctionType = iFuncType;" +
                                    "\n\t\t\tViewByFunction(iFunctionType);" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void BindData_DropDownList()" +
                                "\n\t\t{" +
                                "\n\t\t\t//List<DDLEO> lst = new List<DDLEO>();" +
                                "\n\t\t\t//DataTable dt = SqlDataProvider.getCategoryByType(SelectList_Type_C.TaiKhoan);" +
                                "\n\t\t\t//lst = (List<DDLEO>)Commons.ConvertDataTableToListObject<DDLEO>(dt, \"DDLEO\", lst.GetType());" +
                                "\n\t\t\t//if (!CommonsCheck.ListObject_OK(lst))" +
                                    "\n\t\t\t\t//lst = new List<DDLEO>();" +
                                "\t\t\t\n//lst.Add(new DDLEO(\"0\", \"\"));" +
                                "\n//" +
                                "\n\t\t\t//ddlFK_iTaiKhoanID.DataSource = lst;" +
                                "\n\t\t\t//ddlFK_iTaiKhoanID.DataTextField = \"Value\";" +
                                "\n\t\t\t//ddlFK_iTaiKhoanID.DataValueField = \"Key\";" +
                                "\n\t\t\t//ddlFK_iTaiKhoanID.DataBind();");

            for (int i = 0; i < colName.Count; i++)
            {
                if (colName[i].bForeignKey)
                {
                    isAddOK = true;
                    sb.Append("\n\t\t\tddl" + colName[i].sColumnName + ".DataSource = GetListConstants.Temp_GLC();" +
                        "\n\t\t\tddl" + colName[i].sColumnName + ".DataTextField = \"Value\";" +
                        "\n\t\t\tddl" + colName[i].sColumnName + ".DataValueField = \"Key\";" +
                        "\n\t\t\tddl" + colName[i].sColumnName + ".DataBind();\n");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\n\t\t}" +
            "\n" +
            "\n\t\tprotected bool CheckInput()" +
            "\n\t\t{" +
                "\n\t\t\tstring strNull = \"\";");
            for (int i = 0; i < colName.Count; i++)
            {
                if (colName[i].bAllowNulls == false && !colName[i].bForeignKey)
                {
                    sb.Append("\n\t\t\tif (string.IsNullOrEmpty(txt" + colName[i].sColumnName + ".Text) == true)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tstrNull += \", \" + lbl" + colName[i].sColumnName + ".Text;" +
                                        "\n\t\t\t\ttxt" + colName[i].sColumnName + ".Focus();" +
                                    "\n\t\t\t}");
                }
            }


            sb.Append("\n\t\t\tif (String.IsNullOrEmpty(strNull))" +
            "\n\t\t\t{" +
                "\n\t\t\t\treturn true;" +
            "\n\t\t\t}" +
            "\n\t\t\telse" +
            "\n\t\t\t{" +
                "\n\t\t\t\tif (ViewMessage != null)" +
                    "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.WARNING, Messages.CAC_TRUONG_BAT_BUOC_PHAI_NHAP + strNull.Substring(2).Replace(\":\", \"\"), null));" +
                "\n\t\t\t\treturn false;" +
            "\n\t\t\t}" +
        "\n\t\t}" +
"\n" +
        "\n\t\tprotected void GetObject(ref " + EntityObject + _EntityObject + ")" +
        "\n\t\t{" +
            "\n\t\t\ttry" +
            "\n\t\t\t{");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    if (colName[i].sSQL_DataType == "float")
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =float.Parse(txt" + colName[i].sColumnName + ".Text);");
                    }
                    else
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(colName[i]) + "(txt" + colName[i].sColumnName + ".Text);");
                    }
                }
                else
                {
                    if (colName[i].sSQL_DataType == "float")
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =float.Parse(this.ddl" + colName[i].sColumnName + ".SelectedValue);");
                    }
                    else
                    {
                        sb.Append("\n\t\t\t\t" + _EntityObject + "." + colName[i].sColumnName + " =Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(colName[i]) + "(ddl" + colName[i].sColumnName + ".SelectedValue);");
                    }

                }
            }
            sb.Append("\n\t\t\t}" +
            "\n\t\t\tcatch(Exception ex)" +
            "\n\t\t\t{" +
                "\n\t\t\t\tif (ViewMessage != null)" +
                    "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.ERROR, ex.Message, null));" +
            "\n\t\t\t}" +
        "\n\t\t}" +
"\n" +
        "\n\t\tprotected void ViewByFunction(Int16 iFuncType)" +
        "\n\t\t{" +
            "\n\t\t\tsetEnableAllInput();" +
            "\n\t\t\tswitch (iFuncType)" +
            "\n\t\t\t{" +
                "\n\t\t\t\tcase FunctionType.Insert:");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    sb.Append("\n\t\t\t\t\ttxt" + colName[i].sColumnName + ".Enabled = true;");
                }
                else
                {
                    sb.Append("\n\t\t\t\t\tddl" + colName[i].sColumnName + ".Enabled = true;");
                }
            }
            sb.Append("\n\t\t\t\t\tToolBarUC1.ViewButtonByFunction(iFunctionType);" +
                "\n\t\t\t\t\tbreak;" +
            "\n\t\t\t\tcase FunctionType.Update: break;" +
            "\n\t\t\t\tcase FunctionType.Delete: break;" +
            "\n\t\t\t\tcase FunctionType.View:");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    sb.Append("\n\t\t\t\t\ttxt" + colName[i].sColumnName + ".Enabled = true;");
                }
                else
                {
                    sb.Append("\n\t\t\t\t\tddl" + colName[i].sColumnName + ".Enabled = true;");
                }
            }
            sb.Append("\n\t\t\t\tToolBarUC1.ViewButtonByFunction(iFunctionType);" +
            "\n\t\t\t\tbreak;" +
    "\n\t\t\t}" +
"\n\t\t}" +
"\n" +
"\n\t\tprotected void setEnableAllInput()" +
"\n\t\t{");
            for (int i = 0; i < colName.Count; i++)
            {
                if (!colName[i].bForeignKey)
                {
                    sb.Append("\n\t\t\ttxt" + colName[i].sColumnName + ".Enabled = false;");
                }
                else
                {
                    sb.Append("\n\t\t\tddl" + colName[i].sColumnName + ".Enabled = false;");
                }
            }
            sb.Append("\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void EventButtonToolBar_Click(object sender, CustomerEventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tswitch (e.iType)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tcase funcButtonToolBar.INSERT_LIST:break;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.INSERT_ITEM:" +
                                            "\n\t\t\t\t\tInsertItem();" +
                                            "\n\t\t\t\t\tbreak;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.UPDATE_ITEM:" +
                                            "\n\t\t\t\t\tUpdateItem();" +
                                            "\n\t\t\t\t\tbreak;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.DELETE_LIST:break;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.DELETE_ITEM:" +
                                            "\n\t\t\t\t\tDeleteItem();" +
                                            "\n\t\t\t\t\tbreak;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.REFRESH_LIST:break;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.EXPORT_EXCEL:break;" +
                                        "\n\t\t\t\tcase funcButtonToolBar.RESET_FORM:" +
                                            "\n\t\t\t\t\tResetForm();" +
                                            "\n\t\t\t\t\tbreak;" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void InsertItem()" +
                                "\n\t\t{" +
                                    "\n\t\t\ttry" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (CheckInput() == true)" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                                            "\n\t\t\t\t\tGetObject(ref " + _EntityObject + ");" +
                                            "\n\t\t\t\t\tif (" + DataAccessObject + ".Insert(" + _EntityObject + ") == true)" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tif (ViewMessage != null)" +
                                                    "\n\t\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.SUCCESS, String.Format(Messages.Them_Thanh_Cong_Ma, Table_Name_C." + tbName + "," + _EntityObject + "." + colName[1].sColumnName + "), null));" +
                                            "\n\t\t\t\t\t}" +
                                            "\n\t\t\t\t\telse" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tif (ViewMessage != null)" +
                                                    "\n\t\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.WARNING, String.Format(Messages.Them_That_Bai_Ma, Table_Name_C." + tbName + "," + _EntityObject + "." + colName[1].sColumnName + "), null));" +
                                            "\n\t\t\t\t\t}" +
                                        "\n\t\t\t\t}" +
                                    "\n\t\t\t}" +
                                    "\n\t\t\tcatch (Exception ex)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (ViewMessage != null)" +
                                            "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.ERROR, ex.Message, null));" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void UpdateItem()" +
                                "\n\t\t{" +
                                    "\n\t\t\ttry" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (CheckInput() == true)" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                                            "\n\t\t\t\t\tGetObject(ref " + _EntityObject + ");" +
                                            "\n\t\t\t\t\tif (" + DataAccessObject + ".Update(" + _EntityObject + ") == true)" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tif (ViewMessage != null)" +
                                                    "\n\t\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.SUCCESS, String.Format(Messages.Sua_Thanh_Cong_Ma_Ten, Table_Name_C." + tbName + "," + _EntityObject + "." + colName[0].sColumnName + "," + _EntityObject + "." + colName[1].sColumnName + "), null));" +
                                            "\n\t\t\t\t\t}" +
                                            "\n\t\t\t\t\telse" +
                                            "\n\t\t\t\t\t{" +
                                                "\n\t\t\t\t\t\tif (ViewMessage != null)" +
                                                    "\n\t\t\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.WARNING, String.Format(Messages.Sua_That_Bai_Ma_Ten, Table_Name_C." + tbName + "," + _EntityObject + "." + colName[0].sColumnName + "," + _EntityObject + "." + colName[1].sColumnName + "), null));" +
                                            "\n\t\t\t\t\t}" +
                                        "\n\t\t\t\t}" +
                                    "\n\t\t\t}" +
                                    "\n\t\t\tcatch (Exception ex)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (ViewMessage != null)" +
                                            "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.ERROR, ex.Message, null));" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void DeleteItem()" +
                                "\n\t\t{" +
                                    "\n\t\t\ttry" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                                        "\n\t\t\t\tGetObject(ref " + _EntityObject + ");" +
                                        "\n\t\t\t\tif (" + DataAccessObject + ".Delete(Convert.ToString(" + _EntityObject + "." + colName[0].sColumnName + ")) == true)" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tif (ViewMessage != null)" +
                                                "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.SUCCESS, String.Format(Messages.Xoa_Thanh_Cong_Ma_Ten, Table_Name_C." + tbName + "," + _EntityObject + "." + colName[0].sColumnName + "," + _EntityObject + "." + colName[1].sColumnName + "), null));" +
                                        "\n\t\t\t\t}" +
                                        "\n\t\t\t\telse" +
                                        "\n\t\t\t\t{" +
                                            "\n\t\t\t\t\tif (ViewMessage != null)" +
                                                "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.WARNING, String.Format(Messages.Xoa_That_Bai_Ma_Ten, Table_Name_C." + tbName + "," + _EntityObject + "." + colName[0].sColumnName + "," + _EntityObject + "." + colName[1].sColumnName + "), null));" +
                                        "\n\t\t\t\t}" +
                                    "\n\t\t\t}" +
                                    "\n\t\t\tcatch (Exception ex)" +
                                    "\n\t\t\t{" +
                                        "\n\t\t\t\tif (ViewMessage != null)" +
                                            "\n\t\t\t\t\tViewMessage(this, new CustomerEventArgs(FunctionSetMsg.ERROR, ex.Message, null));" +
                                    "\n\t\t\t}" +
                                "\n\t\t}" +
                        "\n" +
                                "\n\t\tprotected void ResetForm()" +
                                "\n\t\t{" +
                                    "\n\t\t\t" + EntityObject + _EntityObject + " = new " + EntityObject + "();" +
                                    "\n\t\t\tBindDataDetail(" + _EntityObject + ", iFunctionType);" +
                                "\n\t\t}" +
                            "\n\t}" +
                        "\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_Detail", Constants.FileExtension.AscxCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxDesignerCs_Detail(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP_DESIGNER);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl {" +
                        "\n" +
                            "\n\tpublic partial class " + _DetailUC + "{");
            foreach (ColumnEO item in colName)
            {
                sb.Append("\n\t\t/// <summary>" +
                        "\n\t\t/// lbl" + item.sColumnName + " control." +
                        "\n\t\t/// </summary>" +
                        "\n\t\t/// <remarks>" +
                        "\n\t\t/// Auto-generated field." +
                        "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                        "\n\t\t/// </remarks>" +
                        "\n\t\tprotected global::System.Web.UI.WebControls.Label lbl" + item.sColumnName + ";\n");
                if (!item.bForeignKey)
                {
                    sb.Append("\n\t\t/// <summary>" +
                    "\n\t\t/// txt" + item.sColumnName + " control." +
                    "\n\t\t/// </summary>" +
                    "\n\t\t/// <remarks>" +
                    "\n\t\t/// Auto-generated field." +
                    "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                    "\n\t\t/// </remarks>" +
                    "\n\t\tprotected global::System.Web.UI.WebControls.TextBox txt" + item.sColumnName + ";\n");
                }
                else
                {
                    sb.Append("\n\t\t/// <summary>" +
                    "\n\t\t/// ddl" + item.sColumnName + " control." +
                    "\n\t\t/// </summary>" +
                    "\n\t\t/// <remarks>" +
                    "\n\t\t/// Auto-generated field." +
                    "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                    "\n\t\t/// </remarks>" +
                    "\n\t\tprotected global::System.Web.UI.WebControls.DropDownList ddl" + item.sColumnName + ";");
                }
            }


            sb.Append("\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// ToolBarUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.ToolBarUC ToolBarUC1;" +
                            "\n\t}" +
                        "\n}\n");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_Detail", Constants.FileExtension.AscxDesignerCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncAdminMasterDesignerCs(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("//------------------------------------------------------------------------------" +
                        "\n// <auto-generated>" +
                        "\n//     This code was generated by a tool." +
                        "\n//" +
                        "\n//     Changes to this file may cause incorrect behavior and will be lost if" +
                        "\n//     the code is regenerated. " +
                        "\n// </auto-generated>" +
                        "\n//------------------------------------------------------------------------------" +
                        "\n" +
                        "\nnamespace " + Constants.Information.ProjectName + ".PublicInterface {" +
                        "\n" +
                        "\n" +
                            "\n\tpublic partial class Admin {" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// cphHead control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.ContentPlaceHolder cphHead;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// form1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.HtmlControls.HtmlForm form1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// lblsUsername control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.Label lblsUsername;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// cphBody control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.ContentPlaceHolder cphBody;" +
                            "\n\t}" +
                        "}\n");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.PublicInterface, Constants.FolderTemp.Bootstrap_Admin, Constants.FileExtension.MasterDesignerCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncAdminMasterCs(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web;" +
                        "\nusing System.Web.UI;" +
                        "\nusing System.Web.UI.WebControls;" +
                        "\nusing EntityObject;" +
                        "\nusing SharedLibraries;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("namespace " + Constants.Information.ProjectName + ".PublicInterface" +
                        "\n{" +
                            "\n\tpublic partial class Admin : System.Web.UI.MasterPage" +
                            "\n\t{" +
                                "\n\t\tprotected void Page_Load(object sender, EventArgs e)" +
                                "\n\t\t{" +
                                    "\n\t\t\tlblsUsername.Text = \"" + Constants.Information.Author + "\";" +
                                "\n\t\t}" +
                            "\n\t}" +
                        "\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.PublicInterface, Constants.FolderTemp.Bootstrap_Admin, Constants.FileExtension.MasterCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncAdminMaster(List<String> tblName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<%@ Master Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"Admin.Master.cs\" Inherits=\"" + Constants.Information.ProjectName + "." + Constants.FolderTemp.PublicInterface + "." + Constants.FolderTemp.Bootstrap_Admin + "\" %>" +
"\n" +
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" +
"\n" +
"\n<html xmlns=\"http://www.w3.org/1999/xhtml\">" +
"\n<head runat=\"server\">" +
    "\n\t<title>Quản trị</title>" +
    "\n\t<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />" +
    "\n\t<link href=\"../App_Themes/bootstrap.min.css\" rel=\"stylesheet\">" +
"\n" +
    "\n\t<!-- MetisMenu CSS -->" +
    "\n\t<link href=\"../App_Themes/metisMenu.min.css\" rel=\"stylesheet\">" +
"\n" +
    "\n\t<!-- Custom CSS -->" +
    "\n\t<link href=\"../App_Themes/sb-admin-2.css\" rel=\"stylesheet\">" +
"\n" +
    "\n\t<!-- Custom Fonts -->" +
    "\n\t<link href=\"../Fonts/css/font-awesome.min.css\" rel=\"stylesheet\" type=\"text/css\">" +
    "\n\t<link href=\"../App_Themes/addnew.css\" rel=\"stylesheet\" type=\"text/css\">" +
"\n" +
    "\n\t<script type=\"text/javascript\" src=\"../Scripts/jquery-1.4.1.min.js\"></script>" +
 "\n" +
    "\n\t<script type=\"text/javascript\">" +
        "\n\t\t$(document).ready(function () {" +
            "\n\t\t\t$('form ~ div').hide();" +
        "\n\t\t});" +
    "\n\t</script>" +
    "\n\t<asp:ContentPlaceHolder ID=\"cphHead\" runat=\"server\"></asp:ContentPlaceHolder>" +
"\n</head>" +
"\n<body>" +
    "\n\t<form id=\"form1\" runat=\"server\">" +
    "\n\t<div id=\"wrapper\">" +
        "\n\t\t<!-- Navigation -->" +
        "\n\t\t<nav class=\"navbar navbar-default navbar-static-top\" role=\"navigation\" style=\"margin-bottom: 0\">" +
            "\n\t\t\t<div class=\"navbar-header\">" +
                "\n\t\t\t\t<button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">" +
                    "\n\t\t\t\t\t<span class=\"sr-only\">Toggle navigation</span>" +
                    "\n\t\t\t\t\t<span class=\"icon-bar\"></span>" +
                    "\n\t\t\t\t\t<span class=\"icon-bar\"></span>" +
                    "\n\t\t\t\t\t<span class=\"icon-bar\"></span>" +
                "\n\t\t\t\t</button>" +
                "\n\t\t\t\t<a class=\"navbar-brand\" href=\"../Default.aspx\">Homepage</a>" +
            "\n\t\t\t</div>" +
            "\n\t\t\t<!-- /.navbar-header -->" +
"\n" +
            "\n\t\t\t<ul class=\"nav navbar-top-links navbar-right\">" +
                "\n\t\t\t\t<li class=\"dropdown\">" +
                    "\n\t\t\t\t\t<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">" +
                        "\n\t\t\t\t\t\t<i class=\"fa fa-envelope fa-fw\"></i>  <i class=\"fa fa-caret-down\"></i>" +
                    "\n\t\t\t\t\t</a>" +
                    "\n\t\t\t\t\t<ul class=\"dropdown-menu dropdown-messages\">" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<strong>John Smith</strong>" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted\">" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<em>Yesterday</em>" +
                                    "\n\t\t\t\t\t\t\t\t\t</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                                "\n\t\t\t\t\t\t\t\t<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<strong>John Smith</strong>" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted\">" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<em>Yesterday</em>" +
                                    "\n\t\t\t\t\t\t\t\t\t</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                                "\n\t\t\t\t\t\t\t\t<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<strong>John Smith</strong>" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted\">" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<em>Yesterday</em>" +
                                    "\n\t\t\t\t\t\t\t\t\t</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                                "\n\t\t\t\t\t\t\t\t<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a class=\"text-center\" href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<strong>Read All Messages</strong>" +
                                "\n\t\t\t\t\t\t\t\t<i class=\"fa fa-angle-right\"></i>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                    "\n\t\t\t\t\t</ul>" +
                    "\n\t\t\t\t\t<!-- /.dropdown-messages -->" +
                "\n\t\t\t\t</li>" +
                "\n\t\t\t\t<!-- /.dropdown -->" +
                "\n\t\t\t\t<li class=\"dropdown\">" +
                    "\n\t\t\t\t\t<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">" +
                        "\n\t\t\t\t\t\t<i class=\"fa fa-tasks fa-fw\"></i>  <i class=\"fa fa-caret-down\"></i>" +
                    "\n\t\t\t\t\t</a>" +
                    "\n\t\t\t\t\t<ul class=\"dropdown-menu dropdown-tasks\">" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<p>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<strong>Task 1</strong>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted\">40% Complete</span>" +
                                    "\n\t\t\t\t\t\t\t\t\t</p>" +
                                    "\n\t\t\t\t\t\t\t\t\t<div class=\"progress progress-striped active\">" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<div class=\"progress-bar progress-bar-success\" role=\"progressbar\" aria-valuenow=\"40\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 40%\">" +
                                            "\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"sr-only\">40% Complete (success)</span>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t\t\t\t</div>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<p>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<strong>Task 2</strong>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted\">20% Complete</span>" +
                                    "\n\t\t\t\t\t\t\t\t\t</p>" +
                                    "\n\t\t\t\t\t\t\t\t\t<div class=\"progress progress-striped active\">" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<div class=\"progress-bar progress-bar-info\" role=\"progressbar\" aria-valuenow=\"20\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 20%\">" +
                                            "\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"sr-only\">20% Complete</span>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t\t\t\t</div>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<p>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<strong>Task 3</strong>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted\">60% Complete</span>" +
                                    "\n\t\t\t\t\t\t\t\t\t</p>" +
                                    "\n\t\t\t\t\t\t\t\t\t<div class=\"progress progress-striped active\">" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<div class=\"progress-bar progress-bar-warning\" role=\"progressbar\" aria-valuenow=\"60\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 60%\">" +
                                            "\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"sr-only\">60% Complete (warning)</span>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t\t\t\t</div>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<p>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<strong>Task 4</strong>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted\">80% Complete</span>" +
                                    "\n\t\t\t\t\t\t\t\t\t</p>" +
                                    "\n\t\t\t\t\t\t\t\t\t<div class=\"progress progress-striped active\">" +
                                        "\n\t\t\t\t\t\t\t\t\t\t<div class=\"progress-bar progress-bar-danger\" role=\"progressbar\" aria-valuenow=\"80\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 80%\">" +
                                            "\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"sr-only\">80% Complete (danger)</span>" +
                                        "\n\t\t\t\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t\t\t\t</div>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a class=\"text-center\" href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<strong>See All Tasks</strong>" +
                                "\n\t\t\t\t\t\t\t\t<i class=\"fa fa-angle-right\"></i>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                    "\n\t\t\t\t\t</ul>" +
                    "\n\t\t\t\t\t<!-- /.dropdown-tasks -->" +
                "\n\t\t\t\t</li>" +
                "\n\t\t\t\t<!-- /.dropdown -->" +
                "\n\t\t\t\t<li class=\"dropdown\">" +
                    "\n\t\t\t\t\t<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">" +
                        "\n\t\t\t\t\t\t<i class=\"fa fa-bell fa-fw\"></i>  <i class=\"fa fa-caret-down\"></i>" +
                    "\n\t\t\t\t\t</a>" +
                    "\n\t\t\t\t\t<ul class=\"dropdown-menu dropdown-alerts\">" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<i class=\"fa fa-comment fa-fw\"></i> New Comment" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted small\">4 minutes ago</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<i class=\"fa fa-twitter fa-fw\"></i> 3 New Followers" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted small\">12 minutes ago</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<i class=\"fa fa-envelope fa-fw\"></i> Message Sent" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted small\">4 minutes ago</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<i class=\"fa fa-tasks fa-fw\"></i> New Task" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted small\">4 minutes ago</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<div>" +
                                    "\n\t\t\t\t\t\t\t\t\t<i class=\"fa fa-upload fa-fw\"></i> Server Rebooted" +
                                    "\n\t\t\t\t\t\t\t\t\t<span class=\"pull-right text-muted small\">4 minutes ago</span>" +
                                "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li>" +
                            "\n\t\t\t\t\t\t\t<a class=\"text-center\" href=\"#\">" +
                                "\n\t\t\t\t\t\t\t\t<strong>See All Alerts</strong>" +
                                "\n\t\t\t\t\t\t\t\t<i class=\"fa fa-angle-right\"></i>" +
                            "\n\t\t\t\t\t\t\t</a>" +
                        "\n\t\t\t\t\t\t</li>" +
                    "\n\t\t\t\t\t</ul>" +
                    "\n\t\t\t\t\t<!-- /.dropdown-alerts -->" +
                "\n\t\t\t\t</li>" +
                "\n\t\t\t\t<!-- /.dropdown -->" +
                "\n\t\t\t\t<li class=\"dropdown\">" +
                    "\n\t\t\t\t\t<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">" +
                        "\n\t\t\t\t\t\t<i class=\"fa fa-user fa-fw\"></i>  <i class=\"fa fa-caret-down\"></i>" +
                    "\n\t\t\t\t\t</a>" +
                    "\n\t\t\t\t\t<ul class=\"dropdown-menu dropdown-user\">" +
                        "\n\t\t\t\t\t\t<li><a href=\"../Admin/Profile.aspx?iType=View\"><i class=\"fa fa-user fa-fw\"></i> <asp:Label ID=\"lblsUsername\" runat=\"server\"></asp:Label></a></li>" +
                        "\n\t\t\t\t\t\t<li><a href=\"../Admin/Profile.aspx?iType=Setting\"><i class=\"fa fa-gear fa-fw\"></i> Settings</a></li>" +
                        "\n\t\t\t\t\t\t<li class=\"divider\"></li>" +
                        "\n\t\t\t\t\t\t<li><a href=\"../Account/Login.aspx\"><i class=\"fa fa-sign-out fa-fw\"></i> Logout</a></li>" +
                    "\n\t\t\t\t\t</ul>" +
                    "\n\t\t\t\t\t<!-- /.dropdown-user -->" +
                "\n\t\t\t\t</li>" +
                "\n\t\t\t\t<!-- /.dropdown -->" +
            "\n\t\t\t</ul>" +
            "\n\t\t\t<!-- /.navbar-top-links -->" +
"\n" +
            "\n\t\t\t<div class=\"navbar-default sidebar\" role=\"navigation\">" +
                "\n\t\t\t\t<div class=\"sidebar-nav navbar-collapse\">" +
                    "\n\t\t\t\t\t<ul class=\"nav\" id=\"side-menu\">" +
                        "\n\t\t\t\t\t\t<li class=\"sidebar-search\">" +
                            "\n\t\t\t\t\t\t\t<div class=\"input-group custom-search-form\">" +
                                "\n\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form-control\" placeholder=\"Search...\">" +
                                "\n\t\t\t\t\t\t\t\t<span class=\"input-group-btn\">" +
                                    "\n\t\t\t\t\t\t\t\t\t<button class=\"btn btn-default\" type=\"button\"><i class=\"fa fa-search\"></i></button>" +
                                "\n\t\t\t\t\t\t\t\t</span>" +
                            "\n\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t<!-- /input-group -->" +
                        "\n\t\t\t\t\t\t</li>");
            for (int i = 0; i < tblName.Count; i++)
            {
                string temp = tblName[i];
                if (temp.PadRight(3, ' ').Contains("tbl"))
                {
                    temp = temp.Substring(3);
                }
                sb.Append("\n\t\t\t\t\t\t<li><a href=\"../Admin/" + temp + "UI.aspx\"><i class=\"fa fa-dashboard fa-fw\"></i> " + temp + "</a></li>");
            }


            sb.Append("\n\t\t\t\t\t</ul>" +
    "\n\t\t\t\t</div>" +
    "\n\t\t\t\t<!-- /.sidebar-collapse -->" +
"\n\t\t\t</div>" +
"\n\t\t\t<!-- /.navbar-static-side -->" +
"\n\t\t</nav>" +
"\n" +
"\n\t\t<!-- Page Content -->" +
"\n\t\t<div id=\"page-wrapper\">" +
"\n\t\t\t<asp:ContentPlaceHolder ID=\"cphBody\" runat=\"server\"></asp:ContentPlaceHolder>" +
"\n\t\t</div>" +
"\n\t\t<!-- /#page-wrapper -->" +
"\n" +
"\n\t</div>" +
"\n\t<!-- /#wrapper -->" +
"\n" +
"\n\t<!-- jQuery Version 1.11.0 -->" +
"\n\t<script src=\"../Scripts/jquery-1.11.0.js\"></script>" +
"\n" +
"\n\t<!-- Bootstrap Core JavaScript -->" +
"\n\t<script src=\"../Scripts/bootstrap.min.js\"></script>" +
"\n" +
"\n\t<!-- Metis Menu Plugin JavaScript -->" +
"\n\t<script src=\"../Scripts/metisMenu.min.js\"></script>" +
"\n" +
"\n\t<!-- Custom Theme JavaScript -->" +
"\n\t<script src=\"../Scripts/sb-admin-2.js\"></script>" +
"\n\t</form>" +
"\n</body>" +
"\n</html>");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.PublicInterface, Constants.FolderTemp.Bootstrap_Admin, Constants.FileExtension.Master), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }





















        public static void fncBootstrapAscx_All_New(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"" + _NewUC + ".ascx.cs\" Inherits=\"" + Constants.Information.ProjectName + ".UserControl." + _NewUC + "\" %>" +
                        "\n<%@ Register Assembly=\"CKEditor.NET\" Namespace=\"CKEditor.NET\" TagPrefix=\"CKEditor\" %>" +
                        "\n<%@ Register src=\"~/UserControl/Title_FormUC.ascx\" tagname=\"Title_FormUC\" tagprefix=\"uc1\" %>" +
                        "\n<%@ Register src=\"~/UserControl/MsgUC.ascx\" tagname=\"MsgUC\" tagprefix=\"uc2\" %>" +
                        "\n<%@ Register src=\"~/UserControl/ToolBarUC.ascx\" tagname=\"ToolBarUC\" tagprefix=\"uc3\" %>" +
                        "\n<%@ Register src=\"~/UserControl/SearchUI.ascx\" tagname=\"SearchUI\" tagprefix=\"uc4\" %>\n" +
                        "\n<uc1:Title_FormUC ID=\"Title_FormUC1\" runat=\"server\" />" +
                        "\n<uc2:MsgUC ID=\"MsgUC1\" runat=\"server\" />" +
                        "\n<uc3:ToolBarUC ID=\"ToolBarUC1\" runat=\"server\" OnEventButtonToolBar=\"EventButtonToolBar_Click\" OnEventSelectChange=\"EventSelectChange_Click\"/>" +
                        "\n<div class=\"container-fluid-md\">" +
                        "\n<asp:MultiView ID=\"mtvMain\" runat=\"server\" ActiveViewIndex=\"0\">" +
                        "\n\t<asp:View ID=\"vList\" runat=\"server\">" +
                        "\n\t\t<div class=\"panel panel-default panel-light\">" +
                        "\n\t\t\t<div class=\"panel-heading\">" +
                        "\n\t\t\t\t<uc4:SearchUI ID=\"SearchUI1\" runat=\"server\" OnSearch=\"SearchUI_Click\" />" +
                        "\n\t\t\t</div>" +
                        "\n\t\t\t<div class=\"panel-body table-responsive\" id=\"divWrapGrid\">" +
                        "\n\t\t\t\t<asp:GridView ID=\"grvList\" runat=\"server\" CssClass=\"table table-striped table-bordered table-hover dataTable no-footer styleGrid\" " +
                        "\n\t\t\t\t\tAutoGenerateColumns=\"False\" AutoGenerateCheckBoxColumn=\"True\" FileTypeDownload=\"Excel\" Width=\"100%\" AllowPaging=\"True\" ShowHeaderWhenEmpty=\"True\" " +
                        "\n\t\t\t\t\tDataKeyNames=\"" + colName[0].sColumnName + "\" EmptyDataText=\"Không có dữ liệu nào thỏa mãn điều kiện tìm kiếm!\" OnRowCommand=\"grvList_RowCommand\" " +
                        "\n\t\t\t\t\tOnPageIndexChanging=\"grvList_PageIndexChanging\" PageSize=\"20\" AllowSorting=\"true\" OnSorting=\"grvList_Sorting\">" +
                        "\n\t\t\t\t\t<AlternatingRowStyle CssClass=\"GridAlternatingItem\"></AlternatingRowStyle>" +
                        "\n\t\t\t\t\t<Columns>" +
                        "\n\t\t\t\t\t\t<asp:TemplateField>" +
                        "\n\t\t\t\t\t\t\t<HeaderTemplate>" +
                        "\n\t\t\t\t\t\t\t\t<input id=\"chkHead\" type=\"checkbox\" onclick=\"checkAll(this,'divWrapGrid')\" runat=\"server\" />" +
                        "\n\t\t\t\t\t\t\t</HeaderTemplate>" +
                        "\n\t\t\t\t\t\t\t<ItemTemplate>" +
                        "\n\t\t\t\t\t\t\t\t<asp:CheckBox ID=\"chkItem\" runat=\"server\" />" +
                        "\n\t\t\t\t\t\t\t</ItemTemplate>" +
                        "\n\t\t\t\t\t\t\t<ItemStyle HorizontalAlign=\"Center\" />" +
                        "\n\t\t\t\t\t\t</asp:TemplateField>" +
                        "\n\t\t\t\t\t\t<asp:TemplateField>" +
                        "\n\t\t\t\t\t\t\t<ItemTemplate>" +
                        "\n\t\t\t\t\t\t\t\t<asp:LinkButton ID=\"cmdDetail\" runat=\"server\" CommandName=\"cmdView\" Width=\"90px\" CommandArgument='<%#Container.DataItemIndex %>'>Chi tiết</asp:LinkButton>" +
                        "\n\t\t\t\t\t\t\t</ItemTemplate>" +
                        "\n\t\t\t\t\t\t\t<ItemStyle HorizontalAlign=\"Center\" />" +
                        "\n\t\t\t\t\t\t</asp:TemplateField>");
            foreach (var item in colName)
            {
                sb.Append("\n\t\t\t\t\t\t<asp:BoundField DataField=\"" + item.sColumnName + "\" HeaderText=\"" + ConvertNew.getNameEx(item) + "\" SortExpression=\"" + item.sColumnName + "\"" + ConvertNew.FormatDataTypeSQLForColumnGrid(item) + ">" +
                        "\n\t\t\t\t\t\t\t<ItemStyle Wrap=\"true\" CssClass=\"" + ConvertNew.ConvertDataTypeSQLtoCssClass(item) + "\"/>" +
                        "\n\t\t\t\t\t\t</asp:BoundField>");
            }
            sb.Append("\n\t\t\t\t\t</Columns>" +
                        "\n\t\t\t\t\t<PagerStyle CssClass=\"numberpagestyle\" />" +
                        "\n\t\t\t\t\t<HeaderStyle CssClass=\"headerpagestyle\" />" +
                        "\n\t\t\t\t\t<EmptyDataRowStyle HorizontalAlign=\"Center\" />" +
                        "\n\t\t\t\t</asp:GridView>" +
                        "\n\t\t\t</div>" +
                        "\n\t\t\t<div class=\"panel-footer\">" +
                        "\n\t\t\t\t<asp:Label id=\"lblRowCount\" runat=\"server\" ForeColor=\"Blue\" Font-Bold=\"True\" ></asp:Label>" +
                        "\n\t\t\t</div>" +
                        "\n\t\t</div>" +
                        "\n\t</asp:View>" +
                        "\n\t<asp:View ID=\"vDetail\" runat=\"server\"><br />" +
                        "\n\t\t<div class=\"container-fluid-md\">" +
                        "\n\t\t\t<div class=\"col-md-4 col-lg-3\">" +
                        "\n\t\t\t\t<h4 class=\"media-heading\">Thông tin " + tbName + "</h4>" +
                        "\n\t\t\t\t<p>Cung cấp thông tin về " + tbName + ".</p>" +
                        "\n\t\t\t</div>" +
                        "\n\t\t\t<div class=\"col-md-8 col-lg-9\">" +
                        "\n\t\t\t\t<div class=\"panel panel-default panel-light\">" +
                        "\n\t\t\t\t\t<div class=\"panel-body\">");
            Int32 _iDataTypeLengthTemp = 0;
            foreach (var item in colName)
            {
                Int32.TryParse(Convert.ToString(item.sSQL_DataLength), out _iDataTypeLengthTemp);
                if (item.bIdentity)
                    continue;
                else if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\t\t\t<div class=\"form-group\">" +
                                    "\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + item.sColumnName + "\" runat=\"server\" Text=\"" + ConvertNew.getNameEx(item) + ": \"></asp:Label><i class=\"fa fa-flash notnull\"></i>" +
                                    "\n\t\t\t\t\t\t\t<div class=\"controls divItemCheckBox\">" +
                                    "\n\t\t\t\t\t\t\t\t<asp:CheckBox id=\"chk" + item.sColumnName + "\" runat=\"server\" CssClass=\"form-control\" Text=\"&nbsp;\" />" +
                                    "\n\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t</div>");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                    sb.Append("\n\t\t\t\t\t\t<div class=\"form-group\">" +
                                    "\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + item.sColumnName + "\" runat=\"server\" Text=\"" + ConvertNew.getNameEx(item) + ": \"></asp:Label><i class=\"fa fa-flash notnull\"></i>" +
                                    "\n\t\t\t\t\t\t\t<div class=\"table-responsive\">" +
                                    "\n\t\t\t\t\t\t\t\t<table id=\"" + item.sColumnName + "\" class=\"lstDoubleTableInput table table-striped table-bordered table-hover dataTable no-footer styleGrid\">" +
                                    "\n\t\t\t\t\t\t\t\t\t<tr>" +
                                    "\n\t\t\t\t\t\t\t\t\t\t<th style=\"width: 20%;\">Tên thuộc tính</th>" +
                                    "\n\t\t\t\t\t\t\t\t\t\t<th>Giá trị</th>" +
                                    "\n\t\t\t\t\t\t\t\t\t\t<th style=\"width: 42px; padding: 5px !important;\"></th>" +
                                    "\n\t\t\t\t\t\t\t\t\t</tr>" +
                                    "\n\t\t\t\t\t\t\t\t</table>" +
                                    "\n\t\t\t\t\t\t\t\t<input class=\"" + item.sColumnName + "_DataTextBox1\" type=\"hidden\" value='<%=" + item.sColumnName + "_DataTextBox1%>' />" +
                                    "\n\t\t\t\t\t\t\t\t<input class=\"" + item.sColumnName + "_DataTextBox2\" type=\"hidden\" value='<%=" + item.sColumnName + "_DataTextBox2%>' />" +
                                    "\n\t\t\t\t\t\t\t\t<input id=\"" + item.sColumnName + "_btnAddNewItem\" type=\"button\" value=\"Thêm thuộc tính\" onclick=\"func_DoubleTextBox_AddNewItem(" + item.sColumnName + ")\" />" +
                                    "\n\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t</div>");

                }
                else if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                {
                    sb.Append("\n\t\t\t\t\t\t<div class=\"divListCheckBox\" style=\"height: 300px; overflow-y: scroll;\" >" +
                                    "\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + item.sColumnName + "\" runat=\"server\" Text=\"" + ConvertNew.getNameEx(item) + ": \"></asp:Label><i class=\"fa fa-flash notnull\"></i>" +
                                    "\n\t\t\t\t\t\t\t<center class=\"divItemCheckBox\">Click để chọn tất cả <input id=\"chkItem" + item.sColumnName + "\" type=\"checkbox\" onclick=\"checkAll(this, 'div" + item.sColumnName + "');\"/><label for=\"chkItem" + item.sColumnName + "\">&nbsp;</label><hr class=\"hr_style\" /></center>" +
                                    "\n\t\t\t\t\t\t\t<div id=\"divList" + item.sColumnName + "\" runat=\"server\">" +
                                    "\n\t\t\t\t\t\t\t\t<div id=\"div" + item.sColumnName + "\">" +
                                    "\n\t\t\t\t\t\t\t\t\t<asp:CheckBoxList ID=\"cblList" + item.sColumnName + "\" runat=\"server\" RepeatLayout=\"OrderedList\"></asp:CheckBoxList>" +
                                    "\n\t\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t</div>");

                }
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                {
                    sb.Append("\n\t\t\t\t\t\t<div class=\"form-group\">" +
                                    "\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + item.sColumnName + "\" runat=\"server\" Text=\"" + ConvertNew.getNameEx(item) + ": \"></asp:Label><i class=\"fa fa-flash notnull\"></i>" +
                                    "\n\t\t\t\t\t\t\t<div class=\"controls\">" +
                                    "\n\t\t\t\t\t\t\t\t<asp:DropDownList id=\"ddl" + item.sColumnName + "\" runat=\"server\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(item) + "></asp:DropDownList>" +
                                    "\n\t\t\t\t\t\t\t</div>" +
                                    "\n\t\t\t\t\t\t</div>");
                }
                else
                {
                    sb.Append("\n\t\t\t\t\t\t<div class=\"form-group\">" +
                                    "\n\t\t\t\t\t\t\t<asp:Label id=\"lbl" + item.sColumnName + "\" runat=\"server\" Text=\"" + ConvertNew.getNameEx(item) + ": \"></asp:Label><i class=\"fa fa-flash notnull\"></i>" +
                                    "\n\t\t\t\t\t\t\t<div class=\"controls\">");

                    if (_iDataTypeLengthTemp > 200 && _iDataTypeLengthTemp <= 500)
                        sb.Append("\n\t\t\t\t\t\t\t\t<asp:TextBox id=\"txt" + item.sColumnName + "\" runat=\"server\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(item) + " Rows=\"3\" TextMode=\"MultiLine\" ></asp:TextBox>");
                    else if (_iDataTypeLengthTemp > 500 || _iDataTypeLengthTemp < 0)
                        sb.Append("\n\t\t\t\t\t\t\t\t<CKEditor:CKEditorControl id=\"txt" + item.sColumnName + "\" runat=\"server\" CssClass=\"form-control\" autocomplete=\"off\" ></CKEditor:CKEditorControl>");
                    else
                        sb.Append("\n\t\t\t\t\t\t\t\t<asp:TextBox id=\"txt" + item.sColumnName + "\" runat=\"server\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(item) + "></asp:TextBox>");

                    sb.Append("\n\t\t\t\t\t\t\t</div>" +
                   "\n\t\t\t\t\t\t</div>");
                }

            }
            sb.Append("\n\t\t\t\t\t</div>" +
                        "\n\t\t\t\t</div>" +
                        "\n\t\t\t</div>" +
                        "\n\t\t</div>" +
                        "\n\t\t<div class=\"clearfix\"></div>" +
                        "\n\t\t<div class=\"alert alert-danger\" role=\"alert\">" +
                        "\n\t\t\t<i>Note: Những trường có <i class=\"fa fa-flash notnull\"></i> là bắt buộc.</i>" +
                        "\n\t\t</div>" +
                        "\n\t</asp:View>" +
                        "\n</asp:MultiView>" +
                        "\n</div>" +
                        "\n<br /><br /><br /><br /><br />");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_New", Constants.FileExtension.Ascx), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxCs_All_New(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Data;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web.UI.WebControls;" +
                        "\nusing DataAccessObject;" +
                        "\nusing EntityObject;" +
                        "\nusing ThangNM_LIB.EO;" +
                        "\nusing ThangNM_LIB.FUNC;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl" +
                        "\n{" +
                        "\n\tpublic partial class " + _NewUC + " : System.Web.UI.UserControl" +
                        "\n\t{" +
                        "\n\t\t#region \"Properties & Event\"" +
                        "\n\t\tprotected SortDirection directionState" +
                        "\n\t\t{" +
                        "\n\t\t\tget { return (ViewState[\"directionState\"] == null ? SortDirection.Descending : (SortDirection)ViewState[\"directionState\"]); }" +
                        "\n\t\t\tset { ViewState[\"directionState\"] = value; }" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected Int16 iFunctionType" +
                        "\n\t\t{" +
                        "\n\t\t\tget { return (Int16)ViewState[\"iFunctionType\"]; }" +
                        "\n\t\t\tset { ViewState[\"iFunctionType\"] = value; }" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected " + EntityObject + " objTemp" +
                        "\n\t\t{" +
                        "\n\t\t\tget { return (" + EntityObject + ")ViewState[\"objTemp\"]; }" +
                        "\n\t\t\tset { ViewState[\"objTemp\"] = value; }" +
                        "\n\t\t}\n");
            foreach (var item in colName)
            {
                if (item.bIdentity)
                    sb.Append("\n\t\tprotected " + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + " " + item.sColumnName +
                            "\n\t\t{" +
                            "\n\t\t\tget { return (" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + ")ViewState[\"" + item.sColumnName + "\"]; }" +
                            "\n\t\t\tset { ViewState[\"" + item.sColumnName + "\"] = value; }" +
                            "\n\t\t}");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                    sb.Append("\n\t\tprotected String " + item.sColumnName + "_DataTextBox1;");
                    sb.Append("\n\t\tprotected String " + item.sColumnName + "_DataTextBox2;");
                }
            }
            sb.Append("\n\t\t#endregion\n\n\n\n");



            sb.Append("\n\t\t#region \"Common\"" +
                        "\n\t\tprotected void Page_Load(object sender, EventArgs e)" +      //Page_Load
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setClearMsg();" +
                        "\n\t\t\t\tif (!IsPostBack)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tToolBarUC1.BindData_DropDownList(GetListConstantsEx.ListDefaul());" +
                        "\n\t\t\t\t\tLoadInterface(true, ConstEx.FunctionNew.LIST);" +
                        "\n\t\t\t\t\tBindData_DropDownList();" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void LoadInterface(Boolean isList, Int16 iFunc)" +        //LoadInterface
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif (isList)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tTitle_FormUC1.setTitle(ConstEx.Table_Name_C.Default, iFunc);" +
                        "\n\t\t\t\t\tSearchUI1.ResetFormSearch();" +
                        "\n\t\t\t\t\tmtvMain.SetActiveView(vList);" +
                        "\n\t\t\t\t\tToolBarUC1.setView(iFunc);" +
                        "\n\t\t\t\t\tToolBarUC1.SetDefaultValue(true);" +
                        "\n\t\t\t\t\tBindData_List(null);" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tTitle_FormUC1.setTitle(ConstEx.Table_Name_C.Default, iFunc);" +
                        "\n\t\t\t\t\tmtvMain.SetActiveView(vDetail);" +
                        "\n\t\t\t\t\tBindData_Detail(objTemp, iFunc);" +
                        "\n\t\t\t\t\tToolBarUC1.setView(iFunc);" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void EventButtonToolBar_Click(object sender, CustomerEventArgs e)" +       //EventButtonToolBar_Click
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tswitch (e.iType)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.LIST:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.ListRefresh:" +
                        "\n\t\t\t\t\t\tSearchUI1.ResetFormSearch();" +
                        "\n\t\t\t\t\t\tBindData_List(null);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.ListInsert:" +
                        "\n\t\t\t\t\t\tobjTemp = new " + EntityObject + "();" +
                        "\n\t\t\t\t\t\tLoadInterface(false, ConstEx.FunctionNew.DETAIL_I);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.ListDelete:" +
                        "\n\t\t\t\t\t\tDeleteList();" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.ListExport:" +
                        "\n\t\t\t\t\t\tif (grvList.PageCount > 0)" +
                        "\n\t\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\t\tBindData_List(null);" +
                        "\n\t\t\t\t\t\t\tExportEx.PDF_Export(grvList, \"Default\");" +
                        "\n\t\t\t\t\t\t}" +
                        "\n\t\t\t\t\t\telse" +
                        "\n\t\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, MessagesEx.KHONG_THE_XUAT_FILE);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.ListImport:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.DETAIL_I:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailInsert:" +
                        "\n\t\t\t\t\t\tInsertItem(false);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailSaveAdd:" +
                        "\n\t\t\t\t\t\tInsertItem(true);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.DETAIL_V:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailUpdate:" +
                        "\n\t\t\t\t\t\tUpdateItem();" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailDelete:" +
                        "\n\t\t\t\t\t\tDeleteItem();" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailClone:" +
                        "\n\t\t\t\t\t\tToolBarUC1.setView(ConstEx.FunctionNew.DETAIL_I);" +
                        "\n\t\t\t\t\t\tViewByFunction(ConstEx.FunctionNew.DETAIL_I);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailReport:" +
                        "\n\t\t\t\t\t\tSession[\"objKVDG\"] = new KeyValueDataGroupEO(Convert.ToString(objTemp." + colName[0].sColumnName + "), \"~/Report/rptTemp.rdlc\", null, null);" +
                        "\n\t\t\t\t\t\tPage.ClientScript.RegisterStartupScript(this.GetType(), \"report\" + UniqueID, String.Format(\"window.open('{0}','_blank');\", ResolveUrl(\"~/Admin/AccessUI.aspx?t=report&&tt=\" + ConstEx.TypeReport.DEFAULT)), true);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.OTHER:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailReset:" +
                        "\n\t\t\t\t\t\tResetForm();" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailPreview:" +
                        "\n\t\t\t\t\t\tSession[\"objKVDG\"] = new KeyValueDataGroupEO(Convert.ToString(objTemp." + colName[0].sColumnName + "), null, Convert.ToString(objTemp." + colName[1].sColumnName + "), null);" +
                        "\n\t\t\t\t\t\tPage.ClientScript.RegisterStartupScript(this.GetType(), \"preview\" + UniqueID, String.Format(\"window.open('{0}','_blank');\", ResolveUrl(\"~/Admin/AccessUI.aspx?t=preview&&tt=\" + ConstEx.TypeReport.DEFAULT)), true);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DetailBack:" +
                        "\n\t\t\t\t\t\tLoadInterface(true, ConstEx.FunctionNew.LIST);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.DetailComment:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.DetailPost:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\t//case ConstEx.FunctionNew.DEFAULT:" +
                        "\n\t\t\t\t\t//    break;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.ACCESS_DENIAL:" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.DANGER, String.Format(MessagesEx.Khong_Co_Quyen_Truy_Cap, Security.getUsername(true)), null);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tdefault:" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.CHUC_NANG_KHONG_XAC_DINH, e.iType), null);" +
                        "\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}" +
                        "\n\t\t#endregion\n\n\n\n");


            sb.Append("\n\t\t#region \"List\"" +
                        "\n\t\tprotected void BindData_List(String sSortColumn)" +      //BindData_List
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tList<" + EntityObject + "> lst = new List<" + EntityObject + ">();" +
                        "\n\t\t\t\tstring keysearch = StringEx.Trim(SearchUI1.txtTextSearch.Text).ToUpper();" +
                        "\n\t\t\t\t//DataTable dt = (new " + DataAccessObject + "()).SelectList(ToolBarUC1.ddlStatus.SelectedValue);" +
                        "\n\t\t\t\tDataTable dt = (new " + DataAccessObject + "()).SelectList();" +
                        "\n\t\t\t\tDataView dv = dt.DefaultView;" +
                        "\n\t\t\t\tif (!String.IsNullOrEmpty(sSortColumn))" +
                        "\n\t\t\t\t\tdv.Sort = sSortColumn;" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t\tdv.Sort = \"[" + colName[0].sColumnName + "] DESC\";" +
                        "\n\t\t\t\tdt = dv.ToTable();" +
                        "\n\t\t\t\tvar result = (List<" + EntityObject + ">)ConvertEx.ConvertDataTableToListObject<" + EntityObject + ">(dt, lst.GetType());" +

                        "\n\t\t\t\tif (result != null && result.Count() > 0)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tif (SearchUI1.ddlTypeSearch.SelectedValue.Equals(\"0\"))" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tif (!String.IsNullOrEmpty(keysearch))" +
                        "\n\t\t\t\t\t\t\tresult = result.FindAll(x => StringEx.CompareEx(Convert.ToString(x." + colName[0].sColumnName + "), keysearch));" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tif (!String.IsNullOrEmpty(keysearch))" +
                        "\n\t\t\t\t\t\t\tresult = result.FindAll(x => StringEx.CompareEx(Convert.ToString(x." + colName[1].sColumnName + "), keysearch));" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\tif (result == null || result.Count() <= 0)" +
                        "\n\t\t\t\t\t\tresult = new List<" + EntityObject + ">();" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t\tresult = new List<" + EntityObject + ">();" +
                        "\n\t\t\t\tgrvList.DataSource = result.ToList();" +
                        "\n\t\t\t\tgrvList.DataBind();" +
                        "\n\t\t\t\tlblRowCount.Text = MessagesEx.Tong_So_Ban_Ghi + result.Count();" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void SearchUI_Click(object sender, EventArgs e)" +     //SearchUI_Click
                        "\n\t\t{" +
                        "\n\t\t\tBindData_List(null);" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void EventSelectChange_Click(object sender, CustomerEventArgs e)" +        //EventSelectChange_Click
                        "\n\t\t{" +
                        "\n\t\t\tBindData_List(null);" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvList_RowCommand(object source, GridViewCommandEventArgs e)" +      //grvList_RowCommand
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif (!Security.CheckPermission(ConstEx.FunctionNew.DETAIL_V))" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.DANGER, String.Format(MessagesEx.Khong_Co_Quyen_Truy_Cap, Security.getUsername(true)), null);" +
                        "\n\t\t\t\t\treturn;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\tif (e.CommandName == \"cmdView\")" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tint rowIndex = Convert.ToInt32(e.CommandArgument) % grvList.PageSize;" +
                        "\n\t\t\t\t\t" + EntityObject + " _objTemp = new" + EntityObjectEx + "();" +
                        "\n\t\t\t\t\t_objTemp." + colName[0].sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(colName[0]) + "(grvList.DataKeys[rowIndex].Values[0]);" +
                        "\n\t\t\t\t\t_objTemp = (new " + DataAccessObject + "()).SelectItem(_objTemp);" +
                        "\n\t\t\t\t\tif (_objTemp != null)" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tobjTemp = _objTemp;" +
                        "\n\t\t\t\t\t\tLoadInterface(false, ConstEx.FunctionNew.DETAIL_V);" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, MessagesEx.BAN_GHI_KHONG_TON_TAI_HOAC_DA_BI_XOA);" +
                        "\n\t\t\t\t}" +
                         "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvList_PageIndexChanging(object sender, GridViewPageEventArgs e)" +      //grvList_PageIndexChanging
                        "\n\t\t{" +
                        "\n\t\t\tgrvList.PageIndex = e.NewPageIndex;" +
                        "\n\t\t\tBindData_List(null);" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvList_Sorting(object sender, GridViewSortEventArgs e)" +        //grvList_Sorting
                        "\n\t\t{" +
                        "\n\t\t\tif (directionState == SortDirection.Ascending)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tdirectionState = SortDirection.Descending;" +
                        "\n\t\t\t\tBindData_List(\"[\" + e.SortExpression + \"]\" + \" DESC\");" +
                        "\n\t\t\t}" +
                        "\n\t\t\telse" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tdirectionState = SortDirection.Ascending;" +
                        "\n\t\t\t\tBindData_List(\"[\" + e.SortExpression + \"]\" + \" ASC\");" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void DeleteList()" +       //DeleteList
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tstring lstID = \"\";" +
                        "\n\t\t\t\tstring strUsername = \"\";" +
                        "\n\t\t\t\tforeach (GridViewRow row in grvList.Rows)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tCheckBox chk = (CheckBox)row.FindControl(\"chkItem\");" +
                        "\n\t\t\t\t\tif (chk != null && chk.Checked)" +
                        "\n\t\t\t\t\t\tlstID += \",\" + grvList.DataKeys[row.RowIndex].Values[\"" + colName[0].sColumnName + "\"];" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\tif (String.IsNullOrEmpty(lstID))" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.CHUA_CHON_DONG_NAO_DE_XOA, ConstEx.Table_Name_C.Default));" +
                        "\n\t\t\t\t\treturn;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\tif ((new " + DataAccessObject + "()).DeleteList(lstID))" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.SUCCESS, String.Format(MessagesEx.Xoa_Thanh_Cong_Ma, ConstEx.Table_Name_C.Default, lstID.Substring(1)), null);" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.Xoa_That_Bai_Ma, ConstEx.Table_Name_C.Default, lstID.Substring(1)), null);" +
                        "\n\t\t\t\tBindData_List(null);" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}" +
                        "\n\t\t#endregion\n\n\n\n");



            sb.Append("\n\t\t#region \"Detail\"" +
                        "\n\t\tprotected void BindData_Detail(" + EntityObject + " _objTemp, Int16 iFuncType)" +   //BindData_Detail
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tiFunctionType = iFuncType;" +
                        "\n\t\t\t\tList<KeyValueEO> lstKVTemp = new List<KeyValueEO>();" +
                        "\n\t\t\t\tobjTemp = _objTemp;" +
                        "\n\t\t\t\tBindData_DropDownList();");
            foreach (var item in colName)
            {
                if (item.bIdentity)
                    sb.Append("\n\t\t\t\t" + item.sColumnName + " = _objTemp." + item.sColumnName + ";");
                else if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\tchk" + item.sColumnName + ".Checked = Convert.ToBoolean(_objTemp." + item.sColumnName + ");");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                    sb.Append("\n\t\t\t\tlstKVTemp = (List<KeyValueEO>)JsonEx.Json2ListObject(_objTemp." + item.sColumnName + ", lstKVTemp.GetType());" +
                        "\n\t\t\t\t" + item.sColumnName + "_DataTextBox1= ConvertEx.Convert_KeyValueEO_StringOfArray(lstKVTemp, true, true);" +
                        "\n\t\t\t\t" + item.sColumnName + "_DataTextBox2= ConvertEx.Convert_KeyValueEO_StringOfArray(lstKVTemp, false, true);");
                }
                else if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                    sb.Append("\n\t\t\t\tWebEx.setSelect_ListCheckBox(cblList" + item.sColumnName + ", Convert.ToString(_objTemp." + item.sColumnName + "));");
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                    sb.Append("\n\t\t\t\tWebEx.setSelect_DropDownList(ddl" + item.sColumnName + ", Convert.ToString(_objTemp." + item.sColumnName + "));");
                else
                {
                    if (item.sSQL_DataType == "smalldatetime" || item.sSQL_DataType == "datetime" || item.sSQL_DataType == "date")
                        sb.Append("\n\t\t\t\tWebEx.setText_InputDateTime(txt" + item.sColumnName + ", _objTemp." + item.sColumnName + ");");
                    else
                        sb.Append("\n\t\t\t\ttxt" + item.sColumnName + ".Text = Convert.ToString(_objTemp." + item.sColumnName + ");");
                }
            }

            sb.Append("\n\t\t\t\tViewByFunction(iFuncType);" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}" +
                        "\n" +
                        "\n\t\tprotected void BindData_DropDownList()" +        //BindData_DropDownList
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{");
            foreach (var item in colName)
            {
                if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                {
                    isAddOK = true;
                    sb.Append("\n\t\t\t\tcblList" + item.sColumnName + ".DataSource = GetListConstantsEx.ListDefaul();" +
                      "\n\t\t\t\tcblList" + item.sColumnName + ".DataTextField = \"Value\";" +
                      "\n\t\t\t\tcblList" + item.sColumnName + ".DataValueField = \"Key\";" +
                      "\n\t\t\t\tcblList" + item.sColumnName + ".DataBind();\n");
                }
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                {
                    isAddOK = true;
                    sb.Append("\n\t\t\t\tddl" + item.sColumnName + ".DataSource = GetListConstantsEx.ListDefaul();" +
                        "\n\t\t\t\tddl" + item.sColumnName + ".DataTextField = \"Value\";" +
                        "\n\t\t\t\tddl" + item.sColumnName + ".DataValueField = \"Key\";" +
                        "\n\t\t\t\tddl" + item.sColumnName + ".DataBind();\n");
                }
            }
            if (isAddOK)
            {
                isAddOK = false;
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                       "\n\t\tprotected Boolean CheckInput()" +        //CheckInput
                       "\n\t\t{" +
                       "\n\t\t\ttry" +
                       "\n\t\t\t{" +
                       "\n\t\t\t\tString strNull = \"\";");
            foreach (var item in colName)
            {
                if (item.bIdentity || item.sColumnName.Trim().ToLower().EndsWith("ex") || item.sColumnName.Trim().ToLower().EndsWith("exx") || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                {
                }
                else if (item.bAllowNulls == false && !item.bForeignKey && item.sSQL_DataType != "bit" && item.sSQL_DataType != "boolean")
                    sb.Append("\n\t\t\t\tif (String.IsNullOrEmpty(txt" + item.sColumnName + ".Text))" +
                                "\n\t\t\t\t{" +
                                "\n\t\t\t\t\tstrNull += \", \" + lbl" + item.sColumnName + ".Text;" +
                                "\n\t\t\t\t\ttxt" + item.sColumnName + ".Focus();" +
                                "\n\t\t\t\t}");
            }


            sb.Append("\n\t\t\t\tif (String.IsNullOrEmpty(strNull))" +
                        "\n\t\t\t\t\treturn true;" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, MessagesEx.CAC_TRUONG_BAT_BUOC_PHAI_NHAP + strNull.Substring(2).Replace(\":\", \"\"), null);" +
                        "\n\t\t\t\t\treturn false;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t\treturn false;" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void GetObject(ref " + EntityObject + " _objTemp)" +       //GetObject
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{");
            foreach (var item in colName)
            {
                if (item.bIdentity)
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = " + item.sColumnName + ";");
                else if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.ToBoolean(chk" + item.sColumnName + ".Checked);");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                    sb.Append("\n\t\t\t\tList<KeyValueEO> lstKVTemp = new List<KeyValueEO>();" +
                    "\n\t\t\t\tlstKVTemp = ConvertEx.Convert_ArrayString_KeyValueEO(Request.Form.GetValues(\"" + item.sColumnName + "_ValueTextBox1\"), Request.Form.GetValues(\"" + item.sColumnName + "_ValueTextBox2\"));" +
                    "\n\t\t\t\t" + item.sColumnName + "_DataTextBox1 = ConvertEx.Convert_KeyValueEO_StringOfArray(lstKVTemp, true, true);" +
                    "\n\t\t\t\t" + item.sColumnName + "_DataTextBox2 = ConvertEx.Convert_KeyValueEO_StringOfArray(lstKVTemp, false, true);" +
                    "\n\t\t\t\t_objTemp." + item.sColumnName + " = JsonEx.ListObject2Json(lstKVTemp);");
                }
                else if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = WebEx.getSelect_ListCheckBox(cblList" + item.sColumnName + ", true);");
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                {
                    if (item.sSQL_DataType == "float")
                        sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = float.Parse(this.ddl" + item.sColumnName + ".SelectedValue);");
                    else
                        sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(ddl" + item.sColumnName + ".SelectedValue);");
                }
                else
                {
                    if (item.sSQL_DataType == "float")
                        sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = float.Parse(txt" + item.sColumnName + ".Text);");
                    else
                        sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(txt" + item.sColumnName + ".Text);");
                }
            }
            sb.Append("\n\t\t\t}" +
                        "\n\t\t\tcatch(Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\t_objTemp = null;" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void setEnableAllInput()" +        //setEnableAllInput
                        "\n\t\t{");
            foreach (var item in colName)
            {
                if (item.bIdentity)
                { }
                else if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\tchk" + item.sColumnName + ".Enabled = false;");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                }
                else if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                    sb.Append("\n\t\t\tdivList" + item.sColumnName + ".Disabled = false;");
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                    sb.Append("\n\t\t\tddl" + item.sColumnName + ".Enabled = false;");
                else
                    sb.Append("\n\t\t\ttxt" + item.sColumnName + ".Enabled = false;");
            }
            sb.Append("\n\t\t}\n" +
                        "\n\t\tprotected void ViewByFunction(Int16 iFuncType)" +        //ViewByFunction
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tsetEnableAllInput();" +
                        "\n\t\t\t\tswitch (iFuncType)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DETAIL_I:");
            foreach (var item in colName)
            {
                if (item.bIdentity)
                { }
                else if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\t\t\tchk" + item.sColumnName + ".Enabled = true;");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                }
                else if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                    sb.Append("\n\t\t\t\t\t\tdivList" + item.sColumnName + ".Disabled = true;");
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                    sb.Append("\n\t\t\t\t\t\tddl" + item.sColumnName + ".Enabled = true;");
                else
                    sb.Append("\n\t\t\t\t\t\ttxt" + item.sColumnName + ".Enabled = true;");
            }
            sb.Append("\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t\tcase ConstEx.FunctionNew.DETAIL_V:");
            foreach (var item in colName)
            {
                if (item.bIdentity)
                { }
                else if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\t\t\tchk" + item.sColumnName + ".Enabled = true;");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                }
                else if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                    sb.Append("\n\t\t\t\t\t\tdivList" + item.sColumnName + ".Disabled = true;");
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                    sb.Append("\n\t\t\t\t\t\tddl" + item.sColumnName + ".Enabled = true;");
                else
                    sb.Append("\n\t\t\t\t\t\ttxt" + item.sColumnName + ".Enabled = true;");
            }
            sb.Append("\n\t\t\t\t\t\tbreak;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void InsertItem(Boolean isAddNew)" +       //InsertItem
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif (CheckInput() == true)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\t" + EntityObject + " _objTemp = new " + EntityObject + "();" +
                        "\n\t\t\t\t\tGetObject(ref _objTemp);" +
                        "\n\t\t\t\t\tif (_objTemp == null)" +
                        "\n\t\t\t\t\t\treturn;" +
                        "\n\t\t\t\t\tif ((new " + DataAccessObject + "()).Insert_Update_Delete(_objTemp, ConstEx.Insert_Update_Delete.Insert))" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.SUCCESS, String.Format(MessagesEx.Them_Thanh_Cong_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t\t\tobjTemp = _objTemp;" +
                        "\n\t\t\t\t\t\tif (isAddNew)" +
                        "\n\t\t\t\t\t\t\tResetForm();" +
                        "\n\t\t\t\t\t\telse" +
                        "\n\t\t\t\t\t\t\tLoadInterface(true, ConstEx.FunctionNew.LIST);" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.Them_That_Bai_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void UpdateItem()" +       //UpdateItem
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif (CheckInput() == true)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\t" + EntityObject + " _objTemp = new " + EntityObject + "();" +
                        "\n\t\t\t\t\tGetObject(ref _objTemp);" +
                        "\n\t\t\t\t\tif (_objTemp == null)" +
                        "\n\t\t\t\t\t\treturn;" +
                        "\n\t\t\t\t\tif ((new " + DataAccessObject + "()).Insert_Update_Delete(_objTemp, ConstEx.Insert_Update_Delete.Update))" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.SUCCESS, String.Format(MessagesEx.Sua_Thanh_Cong_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t\t\tobjTemp = _objTemp;" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.Sua_That_Bai_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, null);" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void DeleteItem()" +   //DeleteItem
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\t" + EntityObject + " _objTemp = new " + EntityObject + "();" +
                        "\n\t\t\t\tGetObject(ref _objTemp);" +
                        "\n\t\t\t\tif (_objTemp == null)" +
                        "\n\t\t\t\t\treturn;" +
                        "\n\t\t\t\tif ((new " + DataAccessObject + "()).Insert_Update_Delete(_objTemp, ConstEx.Insert_Update_Delete.Delete))" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.SUCCESS, String.Format(MessagesEx.Xoa_Thanh_Cong_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.Xoa_That_Bai_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void ResetForm()" +    //ResetForm
                        "\n\t\t{" +
                        "\n\t\t\tBindData_Detail(new " + EntityObject + "(), iFunctionType);" +
                        "\n\t\t}" +
                        "\n\t\t#endregion" +
                        "\n\t}" +
                        "\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_New", Constants.FileExtension.AscxCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxDesignerCs_All_New(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP_DESIGNER);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl {" +
                        "\n" +
                            "\n\tpublic partial class " + _NewUC + " {" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// Title_FormUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.Title_FormUC Title_FormUC1;" +
                       "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// MsgUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.MsgUC MsgUC1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// ToolBarUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.ToolBarUC ToolBarUC1;" +
                        "\n" +
                        "\n\t\t/// <summary>" +
                                "\n\t\t/// mtvMain control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.MultiView mtvMain;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// vList control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.View vList;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// SearchUI1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.SearchUI SearchUI1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// grvList control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.GridView grvList;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// lblRowCount control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.Label lblRowCount;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// vDetail control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.View vDetail;");

            Int32 _iDataTypeLengthTemp = 0;
            foreach (ColumnEO item in colName)
            {
                Int32.TryParse(Convert.ToString(item.sSQL_DataLength), out _iDataTypeLengthTemp);
                sb.Append("\n\t\t/// <summary>" +
                        "\n\t\t/// lbl" + item.sColumnName + " control." +
                        "\n\t\t/// </summary>" +
                        "\n\t\t/// <remarks>" +
                        "\n\t\t/// Auto-generated field." +
                        "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                        "\n\t\t/// </remarks>" +
                        "\n\t\tprotected global::System.Web.UI.WebControls.Label lbl" + item.sColumnName + ";\n");
                if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t/// <summary>" +
                    "\n\t\t/// chk" + item.sColumnName + " control." +
                    "\n\t\t/// </summary>" +
                    "\n\t\t/// <remarks>" +
                    "\n\t\t/// Auto-generated field." +
                    "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                    "\n\t\t/// </remarks>" +
                    "\n\t\tprotected global::System.Web.UI.WebControls.CheckBox chk" + item.sColumnName + ";\n");
                else if (item.sColumnName.Trim().ToLower().EndsWith("ex"))
                {
                }
                else if (item.sColumnName.Trim().ToLower().EndsWith("exx"))
                {
                    sb.Append("\n\t\t/// <summary>" +
                    "\n\t\t/// divList" + item.sColumnName + " control." +
                    "\n\t\t/// </summary>" +
                    "\n\t\t/// <remarks>" +
                    "\n\t\t/// Auto-generated field." +
                    "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                    "\n\t\t/// </remarks>" +
                    "\n\t\tprotected global::System.Web.UI.HtmlControls.HtmlGenericControl divList" + item.sColumnName + ";\n" +
                    "\n\t\t/// <summary>" +
                    "\n\t\t/// cblList" + item.sColumnName + " control." +
                    "\n\t\t/// </summary>" +
                    "\n\t\t/// <remarks>" +
                    "\n\t\t/// Auto-generated field." +
                    "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                    "\n\t\t/// </remarks>" +
                    "\n\t\tprotected global::System.Web.UI.WebControls.CheckBoxList cblList" + item.sColumnName + ";\n");
                }
                else if (item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_"))
                    sb.Append("\n\t\t/// <summary>" +
                        "\n\t\t/// ddl" + item.sColumnName + " control." +
                        "\n\t\t/// </summary>" +
                        "\n\t\t/// <remarks>" +
                        "\n\t\t/// Auto-generated field." +
                        "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                        "\n\t\t/// </remarks>" +
                        "\n\t\tprotected global::System.Web.UI.WebControls.DropDownList ddl" + item.sColumnName + ";");
                else
                {
                    if (_iDataTypeLengthTemp > 500 || _iDataTypeLengthTemp < 0)
                        sb.Append("\n\t\t/// <summary>" +
                        "\n\t\t/// txt" + item.sColumnName + " control." +
                        "\n\t\t/// </summary>" +
                        "\n\t\t/// <remarks>" +
                        "\n\t\t/// Auto-generated field." +
                        "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                        "\n\t\t/// </remarks>" +
                        "\n\t\tprotected global::CKEditor.NET.CKEditorControl txt" + item.sColumnName + ";\n");
                    else
                        sb.Append("\n\t\t/// <summary>" +
                        "\n\t\t/// txt" + item.sColumnName + " control." +
                        "\n\t\t/// </summary>" +
                        "\n\t\t/// <remarks>" +
                        "\n\t\t/// Auto-generated field." +
                        "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                        "\n\t\t/// </remarks>" +
                        "\n\t\tprotected global::System.Web.UI.WebControls.TextBox txt" + item.sColumnName + ";\n");
                }
            }

            sb.Append("\n\t}" +
                        "\n}\n");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_New", Constants.FileExtension.AscxDesignerCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }





        public static void fncBootstrapAscx_Single_New(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"" + _NewExUC + ".ascx.cs\" Inherits=\"" + Constants.Information.ProjectName + ".UserControl." + _NewExUC + "\" %>" +
                        "\n<%@ Register Assembly=\"CKEditor.NET\" Namespace=\"CKEditor.NET\" TagPrefix=\"CKEditor\" %>" +
                        "\n<%@ Register src=\"~/UserControl/MsgUC.ascx\" tagname=\"MsgUC\" tagprefix=\"uc2\" %>" +
                        "\n<%@ Register src=\"~/UserControl/SearchUI.ascx\" tagname=\"SearchUI\" tagprefix=\"uc4\" %>\n" +
                        "\n<br /><br />" +
                        "\n<asp:UpdateProgress ID=\"udpLoading\" runat=\"server\" AssociatedUpdatePanelID=\"pnlListEx\">" +
                        "\n\t<ProgressTemplate>" +
                        "\n\t\t<center>" +
                        "\n\t\t\t<img src=\"http://va1en.sftcdn.net/shared/img/interface/loader_bar.gif\" alt=\"please wait\" />" +
                        "\n\t\t</center>" +
                        "\n\t</ProgressTemplate>" +
                        "\n</asp:UpdateProgress>" +
                        "\n<asp:UpdatePanel ID=\"pnlListEx\" runat=\"server\" UpdateMode=\"Conditional\">" +
                        "\n\t<ContentTemplate>" +
                        "\n\t\t<uc2:MsgUC ID=\"MsgUC1\" runat=\"server\" />" +
                        "\n\t\t<div class=\"panel panel-default panel-light\">" +
                        "\n\t\t\t<div class=\"panel-heading\">" +
                        "\n\t\t\t\t<uc4:SearchUI ID=\"SearchUI1\" runat=\"server\" OnSearch=\"SearchUI_Click\" />" +
                        "\n\t\t\t</div>" +
                        "\n\t\t\t<div class=\"table-responsive\">" +
                        "\n\t\t\t\t<asp:GridView ID=\"grvListEx\" runat=\"server\" Width=\"100%\" CssClass=\"table table-striped table-bordered table-hover dataTable no-footer styleGrid\" " +
                        "\n\t\t\t\t\tAutoGenerateColumns=\"False\" AllowPaging=\"True\" ShowFooter=\"True\" FileTypeDownload=\"Excel\" ShowHeaderWhenEmpty=\"True\" " +
                        "\n\t\t\t\t\tEmptyDataText=\"Không có dữ liệu nào thỏa mãn điều kiện tìm kiếm!\" OnPageIndexChanging=\"grvListEx_PageIndexChanging\" " +
                        "\n\t\t\t\t\tOnRowEditing=\"grvListEx_RowEditing\" OnRowUpdating=\"grvListEx_RowUpdating\" OnRowCancelingEdit=\"grvListEx_RowCancelingEdit\" " +
                        "\n\t\t\t\t\tPageSize=\"20\" EnableModelValidation=\"True\" AllowSorting=\"True\" OnSorting=\"grvListEx_Sorting\">" +
                        "\n\t\t\t\t\t<AlternatingRowStyle CssClass=\"GridAlternatingItem\"></AlternatingRowStyle>" +
                        "\n\t\t\t\t\t<Columns>");
            Int32 _iDataTypeLengthTemp = 0;
            for (int i = 0; i < colName.Count; i++)
            {
                Int32.TryParse(Convert.ToString(colName[i].sSQL_DataLength), out _iDataTypeLengthTemp);
                if (colName[i].sSQL_DataType == "bit" || colName[i].sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\t\t\t<asp:TemplateField ItemStyle-Width=\"200px\" HeaderText=\"" + ConvertNew.getNameEx(colName[i]) + "\" SortExpression=\"" + colName[i].sColumnName + "\">" +
                            "\n\t\t\t\t\t\t\t<ItemTemplate>" +
                            "\n\t\t\t\t\t\t\t\t<asp:Label ID=\"lbl" + colName[i].sColumnName + "_V\" runat=\"server\" Text='<%# Eval(\"" + colName[i].sColumnName + "\")%>'></asp:Label>" +
                            "\n\t\t\t\t\t\t\t</ItemTemplate>" +
                            "\n\t\t\t\t\t\t\t<EditItemTemplate>" +
                            "\n\t\t\t\t\t\t\t\t<div class=\"divItemCheckBox\">" +
                            "\n\t\t\t\t\t\t\t\t\t<asp:CheckBox ID=\"chk" + colName[i].sColumnName + "_U\" runat=\"server\" Text=\"&nbsp;\" Checked='<%# Eval(\"" + colName[i].sColumnName + "\")%>' />" +
                            "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</EditItemTemplate>" +
                            "\n\t\t\t\t\t\t\t<FooterTemplate>" +
                            "\n\t\t\t\t\t\t\t\t<div class=\"divItemCheckBox\">" +
                            "\n\t\t\t\t\t\t\t\t\t<asp:CheckBox ID=\"chk" + colName[i].sColumnName + "_I\" runat=\"server\" Text=\"&nbsp;\" />" +
                            "\n\t\t\t\t\t\t\t\t</div>" +
                            "\n\t\t\t\t\t\t\t</FooterTemplate>" +
                            "\n\t\t\t\t\t\t\t<ItemStyle CssClass=\"" + ConvertNew.ConvertDataTypeSQLtoCssClass(colName[i]) + "\" />" +
                            "\n\t\t\t\t\t\t</asp:TemplateField>");
                else
                {
                    sb.Append("\n\t\t\t\t\t\t<asp:TemplateField ItemStyle-Width=\"200px\" HeaderText=\"" + ConvertNew.getNameEx(colName[i]) + "\" SortExpression=\"" + colName[i].sColumnName + "\">" +
                            "\n\t\t\t\t\t\t\t<ItemTemplate>" +
                            "\n\t\t\t\t\t\t\t\t<asp:Label ID=\"lbl" + colName[i].sColumnName + "_V\" runat=\"server\" Text='<%# Eval(\"" + colName[i].sColumnName + "\"" + ConvertNew.FormatDataTypeSQLtoHtml5(colName[i], false) + ")%>'></asp:Label>" +
                            "\n\t\t\t\t\t\t\t</ItemTemplate>" +
                            "");
                    if ((colName[i].bForeignKey || colName[i].sColumnName.Trim().ToLower().StartsWith("fk_")) && !colName[i].sColumnName.Trim().ToLower().EndsWith("ex") && !colName[i].sColumnName.Trim().ToLower().EndsWith("exx"))
                    {
                        sb.Append("\n\t\t\t\t\t\t\t<EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<asp:Label ID=\"lbl" + colName[i].sColumnName + "_T\" runat=\"server\" Text='<%# Eval(\"" + colName[i].sColumnName + "\")%>' Visible=\"false\" ></asp:Label>" +
                                    "\n\t\t\t\t\t\t\t\t<asp:DropDownList ID=\"ddl" + colName[i].sColumnName + "_U\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(colName[i]) + " ></asp:DropDownList>" +
                                    "\n\t\t\t\t\t\t\t</EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t<FooterTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<asp:DropDownList ID=\"ddl" + colName[i].sColumnName + "_I\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(colName[i]) + " ></asp:DropDownList>" +
                                    "\n\t\t\t\t\t\t\t</FooterTemplate>"
                         );
                    }
                    else if (_iDataTypeLengthTemp > 200 && _iDataTypeLengthTemp <= 500)
                    {
                        sb.Append("\n\t\t\t\t\t\t\t<EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<asp:TextBox ID=\"txt" + colName[i].sColumnName + "_U\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(colName[i]) + " Rows=\"3\" TextMode=\"MultiLine\" Text='<%# Eval(\"" + colName[i].sColumnName + "\"" + ConvertNew.FormatDataTypeSQLtoHtml5(colName[i], true) + ")%>'></asp:TextBox>" +
                                    "\n\t\t\t\t\t\t\t</EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t<FooterTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<asp:TextBox ID=\"txt" + colName[i].sColumnName + "_I\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(colName[i]) + " Rows=\"3\" TextMode=\"MultiLine\"></asp:TextBox>" +
                                    "\n\t\t\t\t\t\t\t</FooterTemplate>"
                         );
                    }
                    else if (_iDataTypeLengthTemp > 500 || _iDataTypeLengthTemp < 0)
                    {
                        sb.Append("\n\t\t\t\t\t\t\t<EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<CKEditor:CKEditorControl ID=\"txt" + colName[i].sColumnName + "_U\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" Text='<%# Eval(\"" + colName[i].sColumnName + "\"" + ConvertNew.FormatDataTypeSQLtoHtml5(colName[i], true) + ")%>'></CKEditor:CKEditorControl>" +
                                     "\n\t\t\t\t\t\t\t</EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t<FooterTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<CKEditor:CKEditorControl ID=\"txt" + colName[i].sColumnName + "_I\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" ></CKEditor:CKEditorControl>" +
                                    "\n\t\t\t\t\t\t\t</FooterTemplate>"
                        );
                    }
                    else
                    {
                        sb.Append("\n\t\t\t\t\t\t\t<EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<asp:TextBox ID=\"txt" + colName[i].sColumnName + "_U\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(colName[i]) + " Text='<%# Eval(\"" + colName[i].sColumnName + "\"" + ConvertNew.FormatDataTypeSQLtoHtml5(colName[i], true) + ")%>'></asp:TextBox>" +
                                    "\n\t\t\t\t\t\t\t</EditItemTemplate>" +
                                    "\n\t\t\t\t\t\t\t<FooterTemplate>" +
                                    "\n\t\t\t\t\t\t\t\t<asp:TextBox ID=\"txt" + colName[i].sColumnName + "_I\" runat=\"server\" Width=\"100%\" CssClass=\"form-control\" autocomplete=\"off\" " + ConvertNew.ConvertDataTypeSQLtoHtml5(colName[i]) + "></asp:TextBox>" +
                                    "\n\t\t\t\t\t\t\t</FooterTemplate>"
                        );
                    }

                    sb.Append("\n\t\t\t\t\t\t\t<ItemStyle CssClass=\"" + ConvertNew.ConvertDataTypeSQLtoCssClass(colName[i]) + "\" />" +
                    "\n\t\t\t\t\t\t</asp:TemplateField>");
                }
            }
            sb.Append("\n\t\t\t\t\t\t<asp:CommandField ShowEditButton=\"True\" CancelText=\"Cancel\" DeleteText=\"Delete\" EditText=\"Update\" UpdateText=\"OK\" ControlStyle-CssClass=\"btn btn-warning btn-sm\">" +
                        "\n\t\t\t\t\t\t<ControlStyle CssClass=\"btn btn-warning btn-sm\" />" +
                        "\n\t\t\t\t\t\t</asp:CommandField>" +
                        "\n\t\t\t\t\t\t<asp:TemplateField>" +
                        "\n\t\t\t\t\t\t\t<ItemTemplate>" +
                        "\n\t\t\t\t\t\t\t\t<asp:LinkButton ID=\"lbtnDelete\" runat=\"server\" CommandArgument='<%# Eval(\"" + colName[0].sColumnName + "\")%>' CssClass=\"btn btn-danger btn-sm\" OnClientClick=\"return confirm('Bạn chắc chắn muốn xóa không?')\" Text=\"Delete\" OnClick=\"lbtnDelete_Click\"></asp:LinkButton>" +
                        "\n\t\t\t\t\t\t\t</ItemTemplate>" +
                        "\n\t\t\t\t\t\t\t<FooterTemplate>" +
                        "\n\t\t\t\t\t\t\t\t<asp:Button ID=\"btnInsert\" runat=\"server\" Text=\"Thêm\" OnClick=\"btnInsert_Click\" CssClass=\"btn btn-info btn-sm\" />" +
                        "\n\t\t\t\t\t\t\t</FooterTemplate>" +
                        "\n\t\t\t\t\t\t</asp:TemplateField>" +
                        "\n\t\t\t\t\t</Columns>" +
                        "\n\t\t\t\t\t<PagerStyle CssClass=\"numberpagestyle\" />" +
                        "\n\t\t\t\t\t<HeaderStyle CssClass=\"headerpagestyle\" />" +
                        "\n\t\t\t\t\t<EmptyDataRowStyle HorizontalAlign=\"Center\" />" +
                        "\n\t\t\t\t</asp:GridView>" +
                        "\n\t\t\t</div>" +
                        "\n\t\t\t<div class=\"panel-footer\">" +
                        "\n\t\t\t\t<asp:Label id=\"lblRowCount\" runat=\"server\" ForeColor=\"Blue\" Font-Bold=\"True\" ></asp:Label>" +
                        "\n\t\t\t</div>" +
                        "\n\t\t</div>" +
                        "\n\t</ContentTemplate>" +
                        "\n</asp:UpdatePanel>" +
                        "\n<br /><br /><br /><br /><br />");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_NewEx", Constants.FileExtension.Ascx), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxCs_Single_New(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("using System;" +
                        "\nusing System.Collections.Generic;" +
                        "\nusing System.Data;" +
                        "\nusing System.Linq;" +
                        "\nusing System.Web.UI.WebControls;" +
                        "\nusing CKEditor.NET;" +
                        "\nusing DataAccessObject;" +
                        "\nusing EntityObject;" +
                        "\nusing ThangNM_LIB.FUNC;\n");
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl" +
                        "\n{" +
                        "\n\tpublic partial class " + _NewExUC + " : System.Web.UI.UserControl" +
                        "\n\t{" +
                        "\n\t\t#region \"Properties & Event\"" +
                        "\n\t\tpublic SortDirection directionState" +
                        "\n\t\t{" +
                        "\n\t\t\tget { return (ViewState[\"directionState\"] == null ? SortDirection.Descending : (SortDirection)ViewState[\"directionState\"]); }" +
                        "\n\t\t\tset { ViewState[\"directionState\"] = value; }" +
                        "\n\t\t}\n" +
                        "\n\t\tpublic Int16 iFunctionType" +
                        "\n\t\t{" +
                        "\n\t\t\tget { return (Int16)ViewState[\"iFunctionType\"]; }" +
                        "\n\t\t\tset { ViewState[\"iFunctionType\"] = value; }" +
                        "\n\t\t}\n" +
                        "\n\t\tpublic " + EntityObject + " objTemp" +
                        "\n\t\t{" +
                        "\n\t\t\tget { return (" + EntityObject + ")ViewState[\"objTemp\"]; }" +
                        "\n\t\t\tset { ViewState[\"objTemp\"] = value; }" +
                        "\n\t\t}" +
                        "\n\t\t#endregion\n\n\n\n" +
                        "\n\t\t#region \"Common\"" +
                        "\n\t\tprotected void Page_Load(object sender, EventArgs e)" +      //Page_Load
                        "\n\t\t{" +
                        "\n\t\t\tif (!IsPostBack)" +
                        "\n\t\t\t\tBindData_List(null, -1);" +
                        "\n\t\t}\n" +
                        "\n\t\tpublic void setClearMsgAll()" +           //setClearMsgAll
                        "\n\t\t{" +
                        "\n\t\t\tMsgUC1.setClearMsg();" +
                        "\n\t\t}\n" +
                        "\n\t\tprivate void BindData_List(String sSortColumn, Int32 iRowID)" +    //BindData_List
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tList<" + EntityObject + "> lst = new List<" + EntityObject + ">();" +
                        "\n\t\t\t\tstring keysearch = StringEx.Trim(SearchUI1.txtTextSearch.Text).ToUpper();" +
                        "\n\t\t\t\tDataTable dt = (new " + DataAccessObject + "()).SelectList();" +
                        "\n\t\t\t\tDataView dv = dt.DefaultView;" +
                        "\n\t\t\t\tif (!String.IsNullOrEmpty(sSortColumn))" +
                        "\n\t\t\t\t\tdv.Sort = sSortColumn;" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t\tdv.Sort = \"[" + colName[0].sColumnName + "] DESC\";" +
                        "\n\t\t\t\tdt = dv.ToTable();" +
                        "\n\t\t\t\tvar result = (List<" + EntityObject + ">)ConvertEx.ConvertDataTableToListObject<" + EntityObject + ">(dt, lst.GetType());" +
                        "\n\t\t\t\tif (result != null)" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tif (SearchUI1.ddlTypeSearch.SelectedValue.Equals(\"0\"))" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tif (!String.IsNullOrEmpty(keysearch))" +
                        "\n\t\t\t\t\t\t\tresult = result.FindAll(x => StringEx.CompareEx(x." + colName[0].sColumnName + ".ToString(), keysearch));" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t{" +
                        "\n\t\t\t\t\t\tif (!String.IsNullOrEmpty(keysearch))" +
                        "\n\t\t\t\t\t\t\tresult = result.FindAll(x => StringEx.CompareEx(x." + colName[1].sColumnName + ".ToString(), keysearch));" +
                        "\n\t\t\t\t\t}" +
                        "\n\t\t\t\t\tif (result == null || result.Count() <= 0)" +
                        "\n\t\t\t\t\t\tresult = new List<" + EntityObject + ">();" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t\tresult = new List<" + EntityObject + ">();" +
                        "\n\t\t\t\tgrvListEx.DataSource = result.ToList();" +
                        "\n\t\t\t\tgrvListEx.DataBind();" +
                        "\n\t\t\t\tlblRowCount.Text = MessagesEx.Tong_So_Ban_Ghi + result.Count();" +
                        "\n\t\t\t\tBindData_DropDownList(iRowID);" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprivate void BindData_DropDownList(Int32 iRowID)" +            //BindData_DropDownList
                        "\n\t\t{" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tDropDownList ddlTemp;" +
                        "\n\t\t\t\tLabel lblTemp;");
            foreach (var item in colName)
            {
                if ((item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_")) && !item.sColumnName.Trim().ToLower().EndsWith("ex") && !item.sColumnName.Trim().ToLower().EndsWith("exx"))
                {
                    sb.Append("\n\t\t\t\tddlTemp = (DropDownList)grvListEx.FooterRow.FindControl(\"ddl" + item.sColumnName + "_I\");" +
                                   "\n\t\t\t\tddlTemp.DataSource = GetListConstantsEx.ListDefaul();" +
                                   "\n\t\t\t\tddlTemp.DataTextField = \"Value\";" +
                                   "\n\t\t\t\tddlTemp.DataValueField = \"Key\";" +
                                   "\n\t\t\t\tddlTemp.DataBind();" +
                                   "\n\t\t\t\tif (iRowID >= 0)" +
                                   "\n\t\t\t\t{" +
                                   "\n\t\t\t\t\tlblTemp = (Label)grvListEx.Rows[iRowID].FindControl(\"lbl" + item.sColumnName + "_T\");" +
                                   "\n\t\t\t\t\tddlTemp = (DropDownList)grvListEx.Rows[iRowID].FindControl(\"ddl" + item.sColumnName + "_U\");" +
                                   "\n\t\t\t\t\tddlTemp.DataSource = GetListConstantsEx.ListDefaul();" +
                                   "\n\t\t\t\t\tddlTemp.DataTextField = \"Value\";" +
                                   "\n\t\t\t\t\tddlTemp.DataValueField = \"Key\";" +
                                   "\n\t\t\t\t\tddlTemp.DataBind();" +
                                   "\n\t\t\t\t\tif (lblTemp != null)" +
                                   "\n\t\t\t\t\t\tddlTemp.SelectedValue = lblTemp.Text;" +
                                   "\n\t\t\t\t}\n");
                }
            }
            sb.Append("\n\t\t\t}" +
            "\n\t\t\tcatch (Exception ex)" +
            "\n\t\t\t{" +
            "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
            "\n\t\t\t}" +
            "\n\t\t}" +
            "\n\t\tprotected void SearchUI_Click(object sender, EventArgs e)" +     //SearchUI_Click
            "\n\t\t{" +
            "\n\t\t\tsetClearMsgAll();" +
            "\n\t\t\tBindData_List(null, -1);" +
            "\n\t\t}\n" +
            "\n\t\tprotected void btnInsert_Click(object sender, EventArgs e)" +        //btnInsert_Click
            "\n\t\t{" +
            "\n\t\t\tsetClearMsgAll();" +
            "\n\t\t\ttry" +
            "\n\t\t\t{" +
            "\n\t\t\t\tif (!Security.CheckPermission(ConstEx.FunctionNew.DetailInsert))" +
            "\n\t\t\t\t{" +
            "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.DANGER, String.Format(MessagesEx.Khong_Co_Quyen_Truy_Cap, Security.getUsername(true)), null);" +
            "\n\t\t\t\t\tgrvListEx.EditIndex = -1;" +
            "\n\t\t\t\t\tBindData_List(null, -1);" +
            "\n\t\t\t\t\treturn;" +
            "\n\t\t\t\t}" +
            "\n\t\t\t\t" + EntityObject + " _objTemp = new " + EntityObject + "();");
            Int32 _iDataTypeLengthTemp = 0;
            foreach (var item in colName)
            {
                Int32.TryParse(Convert.ToString(item.sSQL_DataLength), out _iDataTypeLengthTemp);
                if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((CheckBox)grvListEx.FooterRow.FindControl(\"chk" + item.sColumnName + "_I\")).Checked);");
                else if ((item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_")) && !item.sColumnName.Trim().ToLower().EndsWith("ex") && !item.sColumnName.Trim().ToLower().EndsWith("exx"))
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((DropDownList)grvListEx.FooterRow.FindControl(\"ddl" + item.sColumnName + "_I\")).SelectedValue);");
                else if (_iDataTypeLengthTemp > 500 || _iDataTypeLengthTemp < 0)
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((CKEditorControl)grvListEx.FooterRow.FindControl(\"txt" + item.sColumnName + "_I\")).Text);");
                else
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((TextBox)grvListEx.FooterRow.FindControl(\"txt" + item.sColumnName + "_I\")).Text);");
            }
            sb.Append("\n\t\t\t\tif (CheckInput(ref _objTemp))" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tif ((new " + DataAccessObject + "()).Insert_Update_Delete(_objTemp, ConstEx.Insert_Update_Delete.Insert))" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.SUCCESS, String.Format(MessagesEx.Them_Thanh_Cong_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.Them_That_Bai_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t\tBindData_List(null, -1);" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void lbtnDelete_Click(object sender, EventArgs e)" +       //lbtnDelete_Click
                        "\n\t\t{" +
                        "\n\t\t\tsetClearMsgAll();" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif (!Security.CheckPermission(ConstEx.FunctionNew.DetailDelete))" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.DANGER, String.Format(MessagesEx.Khong_Co_Quyen_Truy_Cap, Security.getUsername(true)), null);" +
                        "\n\t\t\t\t\tgrvListEx.EditIndex = -1;" +
                        "\n\t\t\t\t\tBindData_List(null, -1);" +
                        "\n\t\t\t\t\treturn;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\t" + EntityObject + " _objTemp = new " + EntityObject + "();" +
                        "\n\t\t\t\tLinkButton lbtnDelete = (LinkButton)sender;" +
                        "\n\t\t\t\t_objTemp." + colName[0].sColumnName + " = Convert.ToInt32(lbtnDelete.CommandArgument);" +
                        "\n\t\t\t\tif ((new " + DataAccessObject + "()).Insert_Update_Delete(_objTemp, ConstEx.Insert_Update_Delete.Delete))" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.SUCCESS, String.Format(MessagesEx.Xoa_Thanh_Cong_Ma, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + "));" +
                        "\n\t\t\t\telse" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.Xoa_That_Bai_Ma, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + "));" +
                        "\n\t\t\t\tBindData_List(null, -1);" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvListEx_PageIndexChanging(object sender, GridViewPageEventArgs e)" +        //grvListEx_PageIndexChanging
                        "\n\t\t{" +
                        "\n\t\t\tsetClearMsgAll();" +
                        "\n\t\t\tgrvListEx.PageIndex = e.NewPageIndex;" +
                        "\n\t\t\tBindData_List(null, -1);" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvListEx_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)" +   //grvListEx_RowCancelingEdit
                        "\n\t\t{" +
                        "\n\t\t\tsetClearMsgAll();" +
                        "\n\t\t\tgrvListEx.EditIndex = -1;" +
                        "\n\t\t\tBindData_List(null, -1);" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvListEx_RowEditing(object sender, GridViewEditEventArgs e)" +               //grvListEx_RowEditing
                        "\n\t\t{" +
                        "\n\t\t\tsetClearMsgAll();" +
                        "\n\t\t\tif (!Security.CheckPermission(ConstEx.FunctionNew.DetailUpdate))" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.DANGER, String.Format(MessagesEx.Khong_Co_Quyen_Truy_Cap, Security.getUsername(true)), null);" +
                        "\n\t\t\t\tgrvListEx.EditIndex = -1;" +
                        "\n\t\t\t\tBindData_List(null, -1);" +
                        "\n\t\t\t\treturn;" +
                        "\n\t\t\t}" +
                        "\n\t\t\tgrvListEx.EditIndex = e.NewEditIndex;" +
                        "\n\t\t\tBindData_List(null, e.NewEditIndex);" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvListEx_RowUpdating(object sender, GridViewUpdateEventArgs e)" +            //grvListEx_RowUpdating
                        "\n\t\t{" +
                        "\n\t\t\tsetClearMsgAll();" +
                        "\n\t\t\ttry" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tif (!Security.CheckPermission(ConstEx.FunctionNew.DetailUpdate))" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.DANGER, String.Format(MessagesEx.Khong_Co_Quyen_Truy_Cap, Security.getUsername(true)), null);" +
                        "\n\t\t\t\t\treturn;" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t\t" + EntityObject + " _objTemp = new " + EntityObject + "();");
            foreach (var item in colName)
            {
                if (item.sSQL_DataType == "bit" || item.sSQL_DataType == "boolean")
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((CheckBox)grvListEx.Rows[e.RowIndex].FindControl(\"chk" + item.sColumnName + "_U\")).Checked);");
                else if ((item.bForeignKey || item.sColumnName.Trim().ToLower().StartsWith("fk_")) && !item.sColumnName.Trim().ToLower().EndsWith("ex") && !item.sColumnName.Trim().ToLower().EndsWith("exx"))
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((DropDownList)grvListEx.Rows[e.RowIndex].FindControl(\"ddl" + item.sColumnName + "_U\")).SelectedValue);");
                else if (_iDataTypeLengthTemp > 500 || _iDataTypeLengthTemp < 0)
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((CKEditorControl)grvListEx.Rows[e.RowIndex].FindControl(\"txt" + item.sColumnName + "_U\")).Text);");
                else
                    sb.Append("\n\t\t\t\t_objTemp." + item.sColumnName + " = Convert.To" + ConvertNew.ConvertDataTypeSQLtoCsharp(item) + "(((TextBox)grvListEx.Rows[e.RowIndex].FindControl(\"txt" + item.sColumnName + "_U\")).Text);");
            }

            sb.Append("\n\t\t\t\tif (CheckInput(ref _objTemp))" +
                        "\n\t\t\t\t{" +
                        "\n\t\t\t\t\tif ((new " + DataAccessObject + "()).Insert_Update_Delete(_objTemp, ConstEx.Insert_Update_Delete.Update))" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.SUCCESS, String.Format(MessagesEx.Sua_Thanh_Cong_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t\telse" +
                        "\n\t\t\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, String.Format(MessagesEx.Them_That_Bai_Ma_Ten, ConstEx.Table_Name_C.Default, _objTemp." + colName[0].sColumnName + ", _objTemp." + colName[1].sColumnName + "));" +
                        "\n\t\t\t\t\tgrvListEx.EditIndex = -1;" +
                        "\n\t\t\t\t\tBindData_List(null, -1);" +
                        "\n\t\t\t\t}" +
                        "\n\t\t\t}" +
                        "\n\t\t\tcatch (Exception ex)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tprotected void grvListEx_Sorting(object sender, GridViewSortEventArgs e)" +                  //grvListEx_Sorting
                        "\n\t\t{" +
                        "\n\t\t\tsetClearMsgAll();" +
                        "\n\t\t\tif (directionState == SortDirection.Ascending)" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tdirectionState = SortDirection.Descending;" +
                        "\n\t\t\t\tBindData_List(\"[\" + e.SortExpression + \"]\" + \" DESC\", -1);" +
                        "\n\t\t\t}" +
                        "\n\t\t\telse" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tdirectionState = SortDirection.Ascending;" +
                        "\n\t\t\t\tBindData_List(\"[\" + e.SortExpression + \"]\" + \" ASC\", -1);" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\tpublic Boolean CheckInput(ref " + EntityObject + " _objTemp)" +                              //CheckInput
                        "\n\t\t{" +
                        "\n\t\t\tsetClearMsgAll();" +
                        "\n\t\t\tString strNull = \"\";");
            for (int i = 0; i < colName.Count; i++)
            {
                if (colName[i].bAllowNulls == false && !colName[i].bForeignKey && colName[i].sSQL_DataType != "bit" && colName[i].sSQL_DataType != "boolean" && !colName[i].sColumnName.Trim().ToLower().StartsWith("fk_"))
                    sb.Append("\n\t\t\tif (String.IsNullOrEmpty(Convert.ToString(_objTemp." + colName[i].sColumnName + ")))" +
                                "\n\t\t\t\tstrNull += \", \" + grvListEx.Columns[" + i + "].HeaderText;");
            }


            sb.Append("\n\t\t\tif (String.IsNullOrEmpty(strNull))" +
                        "\n\t\t\t\treturn true;" +
                        "\n\t\t\telse" +
                        "\n\t\t\t{" +
                        "\n\t\t\t\tMsgUC1.setNotifications(ConstEx.FunctionSetMsg.WARNING, MessagesEx.CAC_TRUONG_BAT_BUOC_PHAI_NHAP + strNull.Substring(2).Replace(\":\", \"\"), null);" +
                        "\n\t\t\t\treturn false;" +
                        "\n\t\t\t}" +
                        "\n\t\t}\n" +
                        "\n\t\t#endregion" +
                        "\n\t}" +
                        "\n}");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_NewEx", Constants.FileExtension.AscxCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

        public static void fncBootstrapAscxDesignerCs_Single_New(List<ColumnEO> colName, string tbName)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Constants.CSharp.COMMENT_CODE_CSHARP_DESIGNER);
            sb.Append("\nnamespace " + Constants.Information.ProjectName + ".UserControl {" +
                        "\n" +
                            "\n\tpublic partial class " + _NewExUC + " {" +
                        "\n" +
                                "\n\t/// <summary>" +
                                "\n\t/// udpLoading control." +
                                "\n\t/// </summary>" +
                                "\n\t/// <remarks>" +
                                "\n\t/// Auto-generated field." +
                                "\n\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t/// </remarks>" +
                                "\n\tprotected global::System.Web.UI.UpdateProgress udpLoading;" +
                        "\n" +
                                "\n\t/// <summary>" +
                                "\n\t/// pnlListEx control." +
                                "\n\t/// </summary>" +
                                "\n\t/// <remarks>" +
                                "\n\t/// Auto-generated field." +
                                "\n\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t/// </remarks>" +
                                "\n\tprotected global::System.Web.UI.UpdatePanel pnlListEx;" +
                       "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// MsgUC1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.MsgUC MsgUC1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// SearchUI1 control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::" + Constants.Information.ProjectName + ".UserControl.SearchUI SearchUI1;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// grvListEx control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.GridView grvListEx;" +
                        "\n" +
                                "\n\t\t/// <summary>" +
                                "\n\t\t/// lblRowCount control." +
                                "\n\t\t/// </summary>" +
                                "\n\t\t/// <remarks>" +
                                "\n\t\t/// Auto-generated field." +
                                "\n\t\t/// To modify move field declaration from designer file to code-behind file." +
                                "\n\t\t/// </remarks>" +
                                "\n\t\tprotected global::System.Web.UI.WebControls.Label lblRowCount;" +
                            "\n\t}" +
                        "\n}\n");
            try
            {
                System.IO.File.WriteAllText(GetPath_FileName(System.Windows.Forms.Application.StartupPath, Constants.FolderTemp.Bootstrap_UserControl, tbName + "_NewEx", Constants.FileExtension.AscxDesignerCs), sb.ToString(), Encoding.UTF8);
            }
            catch
            {
            }
        }

















        public static string GetPath_FileName(string rootpath, string foldername, string filename, string extension)
        {
            string link = "";
            link = rootpath + "\\" + Constants.Information.Author + "\\" + foldername;
            if (!Directory.Exists(link))
            {
                System.IO.Directory.CreateDirectory(link);
            }
            link = rootpath + "\\" + Constants.Information.Author + "\\" + foldername + "\\" + filename + extension;
            if (File.Exists(link))
            {
                filename = filename + "_1";
                link = rootpath + "\\" + foldername + "\\" + filename + extension;
            }
            return link;
        }

        public static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
        {
            DirectoryInfo dir = new DirectoryInfo(sourceDirName);
            DirectoryInfo[] dirs = dir.GetDirectories();

            // If the source directory does not exist, throw an exception.
            if (!dir.Exists)
            {
                throw new DirectoryNotFoundException(
                    "Source directory does not exist or could not be found: "
                    + sourceDirName);
            }

            // If the destination directory does not exist, create it.
            if (!Directory.Exists(destDirName))
            {
                Directory.CreateDirectory(destDirName);
            }


            // Get the file contents of the directory to copy.
            FileInfo[] files = dir.GetFiles();

            foreach (FileInfo file in files)
            {
                // Create the path to the new copy of the file.
                string temppath = Path.Combine(destDirName, file.Name);

                // Copy the file.
                file.CopyTo(temppath, false);
            }

            // If copySubDirs is true, copy the subdirectories.
            if (copySubDirs)
            {

                foreach (DirectoryInfo subdir in dirs)
                {
                    // Create the subdirectory.
                    string temppath = Path.Combine(destDirName, subdir.Name);

                    // Copy the subdirectories.
                    DirectoryCopy(subdir.FullName, temppath, copySubDirs);
                }
            }
        }
    }
}
